Skip to content

Commit 0cfd1de

Browse files
Expose version_id on google_cloudfunctions_function (#9969) (#6968)
[upstream:781b533bfe7e9f0bff3cf31eaff212fe7f3c4575] Signed-off-by: Modular Magician <[email protected]>
1 parent 32a52d0 commit 0cfd1de

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.changelog/9969.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
Expose version_id on google_cloudfunctions_function
3+
```

google-beta/services/cloudfunctions/resource_cloudfunctions_function.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,11 @@ func ResourceCloudFunctionsFunction() *schema.Resource {
492492
Computed: true,
493493
Description: `Describes the current stage of a deployment.`,
494494
},
495+
"version_id": {
496+
Type: schema.TypeString,
497+
Computed: true,
498+
Description: `The version identifier of the Cloud Function. Each deployment attempt results in a new version of a function being created.`,
499+
},
495500
},
496501
UseJSONNumber: true,
497502
}
@@ -788,6 +793,9 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error
788793
if err := d.Set("project", cloudFuncId.Project); err != nil {
789794
return fmt.Errorf("Error setting project: %s", err)
790795
}
796+
if err := d.Set("version_id", strconv.FormatInt(function.VersionId, 10)); err != nil {
797+
return fmt.Errorf("Error setting version_id: %s", err)
798+
}
791799

792800
return nil
793801
}

google-beta/services/cloudfunctions/resource_cloudfunctions_function_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ func TestAccCloudFunctionsFunction_basic(t *testing.T) {
7272
"entry_point", "helloGET"),
7373
resource.TestCheckResourceAttr(funcResourceName,
7474
"trigger_http", "true"),
75+
resource.TestCheckResourceAttr(funcResourceName,
76+
"version_id", "1"),
7577
testAccCloudFunctionsFunctionHasLabel("my-label", "my-label-value", &function),
7678
testAccCloudFunctionsFunctionHasEnvironmentVariable("TEST_ENV_VARIABLE",
7779
"test-env-variable-value", &function),
@@ -111,6 +113,8 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
111113
t, funcResourceName, &function),
112114
resource.TestCheckResourceAttr(funcResourceName,
113115
"available_memory_mb", "128"),
116+
resource.TestCheckResourceAttr(funcResourceName,
117+
"version_id", "1"),
114118
testAccCloudFunctionsFunctionHasLabel("my-label", "my-label-value", &function),
115119
),
116120
},
@@ -139,6 +143,8 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
139143
"min_instances", "5"),
140144
resource.TestCheckResourceAttr(funcResourceName,
141145
"ingress_settings", "ALLOW_ALL"),
146+
resource.TestCheckResourceAttr(funcResourceName,
147+
"version_id", "2"),
142148
testAccCloudFunctionsFunctionHasLabel("my-label", "my-updated-label-value", &function),
143149
testAccCloudFunctionsFunctionHasLabel("a-new-label", "a-new-label-value", &function),
144150
testAccCloudFunctionsFunctionHasEnvironmentVariable("TEST_ENV_VARIABLE",

0 commit comments

Comments
 (0)