Skip to content

Commit 7edd3b7

Browse files
promote cfn2 to ga (#6388) (#4599)
Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent fb4e18a commit 7edd3b7

File tree

5 files changed

+90
-170
lines changed

5 files changed

+90
-170
lines changed

.changelog/6388.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
cloudfunction2: promote to `google_cloudfunctions2_function` ga
3+
```

google-beta/iam_cloudfunctions2_function_generated_test.go

Lines changed: 60 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package google
1616

1717
import (
18+
"fmt"
1819
"testing"
1920

2021
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -28,22 +29,33 @@ func TestAccCloudfunctions2functionIamBindingGenerated(t *testing.T) {
2829
"role": "roles/viewer",
2930
"project": getTestProjectFromEnv(),
3031

31-
"zip_path": "./test-fixtures/cloudfunctions2/function-source.zip",
32-
"primary_resource_id": "function",
33-
"location": "us-central1",
32+
"zip_path": "./test-fixtures/cloudfunctions2/function-source.zip",
33+
"location": "us-central1",
3434
}
3535

3636
vcrTest(t, resource.TestCase{
3737
PreCheck: func() { testAccPreCheck(t) },
38-
Providers: testAccProvidersOiCS,
38+
Providers: testAccProviders,
3939
Steps: []resource.TestStep{
4040
{
4141
Config: testAccCloudfunctions2functionIamBinding_basicGenerated(context),
4242
},
43+
{
44+
ResourceName: "google_cloudfunctions2_function_iam_binding.foo",
45+
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/functions/%s roles/viewer", getTestProjectFromEnv(), getTestRegionFromEnv(), fmt.Sprintf("tf-test-function-v2%s", context["random_suffix"])),
46+
ImportState: true,
47+
ImportStateVerify: true,
48+
},
4349
{
4450
// Test Iam Binding update
4551
Config: testAccCloudfunctions2functionIamBinding_updateGenerated(context),
4652
},
53+
{
54+
ResourceName: "google_cloudfunctions2_function_iam_binding.foo",
55+
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/functions/%s roles/viewer", getTestProjectFromEnv(), getTestRegionFromEnv(), fmt.Sprintf("tf-test-function-v2%s", context["random_suffix"])),
56+
ImportState: true,
57+
ImportStateVerify: true,
58+
},
4759
},
4860
})
4961
}
@@ -56,19 +68,24 @@ func TestAccCloudfunctions2functionIamMemberGenerated(t *testing.T) {
5668
"role": "roles/viewer",
5769
"project": getTestProjectFromEnv(),
5870

59-
"zip_path": "./test-fixtures/cloudfunctions2/function-source.zip",
60-
"primary_resource_id": "function",
61-
"location": "us-central1",
71+
"zip_path": "./test-fixtures/cloudfunctions2/function-source.zip",
72+
"location": "us-central1",
6273
}
6374

6475
vcrTest(t, resource.TestCase{
6576
PreCheck: func() { testAccPreCheck(t) },
66-
Providers: testAccProvidersOiCS,
77+
Providers: testAccProviders,
6778
Steps: []resource.TestStep{
6879
{
6980
// Test Iam Member creation (no update for member, no need to test)
7081
Config: testAccCloudfunctions2functionIamMember_basicGenerated(context),
7182
},
83+
{
84+
ResourceName: "google_cloudfunctions2_function_iam_member.foo",
85+
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/functions/%s roles/viewer user:[email protected]", getTestProjectFromEnv(), getTestRegionFromEnv(), fmt.Sprintf("tf-test-function-v2%s", context["random_suffix"])),
86+
ImportState: true,
87+
ImportStateVerify: true,
88+
},
7289
},
7390
})
7491
}
@@ -81,21 +98,32 @@ func TestAccCloudfunctions2functionIamPolicyGenerated(t *testing.T) {
8198
"role": "roles/viewer",
8299
"project": getTestProjectFromEnv(),
83100

84-
"zip_path": "./test-fixtures/cloudfunctions2/function-source.zip",
85-
"primary_resource_id": "function",
86-
"location": "us-central1",
101+
"zip_path": "./test-fixtures/cloudfunctions2/function-source.zip",
102+
"location": "us-central1",
87103
}
88104

89105
vcrTest(t, resource.TestCase{
90106
PreCheck: func() { testAccPreCheck(t) },
91-
Providers: testAccProvidersOiCS,
107+
Providers: testAccProviders,
92108
Steps: []resource.TestStep{
93109
{
94110
Config: testAccCloudfunctions2functionIamPolicy_basicGenerated(context),
95111
},
112+
{
113+
ResourceName: "google_cloudfunctions2_function_iam_policy.foo",
114+
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/functions/%s", getTestProjectFromEnv(), getTestRegionFromEnv(), fmt.Sprintf("tf-test-function-v2%s", context["random_suffix"])),
115+
ImportState: true,
116+
ImportStateVerify: true,
117+
},
96118
{
97119
Config: testAccCloudfunctions2functionIamPolicy_emptyBinding(context),
98120
},
121+
{
122+
ResourceName: "google_cloudfunctions2_function_iam_policy.foo",
123+
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/functions/%s", getTestProjectFromEnv(), getTestRegionFromEnv(), fmt.Sprintf("tf-test-function-v2%s", context["random_suffix"])),
124+
ImportState: true,
125+
ImportStateVerify: true,
126+
},
99127
},
100128
})
101129
}
@@ -107,27 +135,20 @@ locals {
107135
project = "%{project}" # Google Cloud Platform Project ID
108136
}
109137
110-
provider "google-beta" {
111-
project = local.project
112-
}
113-
114138
resource "google_storage_bucket" "bucket" {
115-
provider = google-beta
116139
name = "${local.project}-tf-test-gcf-source%{random_suffix}" # Every bucket name must be globally unique
117140
location = "US"
118141
uniform_bucket_level_access = true
119142
}
120143
121144
resource "google_storage_bucket_object" "object" {
122-
provider = google-beta
123145
name = "function-source.zip"
124146
bucket = google_storage_bucket.bucket.name
125147
source = "%{zip_path}" # Add path to the zipped function source code
126148
}
127149
128150
resource "google_cloudfunctions2_function" "function" {
129-
provider = google-beta
130-
name = "tf-test-test-function%{random_suffix}"
151+
name = "tf-test-function-v2%{random_suffix}"
131152
location = "us-central1"
132153
description = "a new function"
133154
@@ -155,9 +176,9 @@ output "function_uri" {
155176
# [END functions_v2_basic]
156177
157178
resource "google_cloudfunctions2_function_iam_member" "foo" {
158-
provider = google-beta
159-
cloud_function = google_cloudfunctions2_function.%{primary_resource_id}.name
160-
location = "%{location}"
179+
project = google_cloudfunctions2_function.function.project
180+
location = google_cloudfunctions2_function.function.location
181+
cloud_function = google_cloudfunctions2_function.function.name
161182
role = "%{role}"
162183
member = "user:[email protected]"
163184
}
@@ -171,27 +192,20 @@ locals {
171192
project = "%{project}" # Google Cloud Platform Project ID
172193
}
173194
174-
provider "google-beta" {
175-
project = local.project
176-
}
177-
178195
resource "google_storage_bucket" "bucket" {
179-
provider = google-beta
180196
name = "${local.project}-tf-test-gcf-source%{random_suffix}" # Every bucket name must be globally unique
181197
location = "US"
182198
uniform_bucket_level_access = true
183199
}
184200
185201
resource "google_storage_bucket_object" "object" {
186-
provider = google-beta
187202
name = "function-source.zip"
188203
bucket = google_storage_bucket.bucket.name
189204
source = "%{zip_path}" # Add path to the zipped function source code
190205
}
191206
192207
resource "google_cloudfunctions2_function" "function" {
193-
provider = google-beta
194-
name = "tf-test-test-function%{random_suffix}"
208+
name = "tf-test-function-v2%{random_suffix}"
195209
location = "us-central1"
196210
description = "a new function"
197211
@@ -219,17 +233,16 @@ output "function_uri" {
219233
# [END functions_v2_basic]
220234
221235
data "google_iam_policy" "foo" {
222-
provider = google-beta
223236
binding {
224237
role = "%{role}"
225238
members = ["user:[email protected]"]
226239
}
227240
}
228241
229242
resource "google_cloudfunctions2_function_iam_policy" "foo" {
230-
provider = google-beta
231-
cloud_function = google_cloudfunctions2_function.%{primary_resource_id}.name
232-
location = "%{location}"
243+
project = google_cloudfunctions2_function.function.project
244+
location = google_cloudfunctions2_function.function.location
245+
cloud_function = google_cloudfunctions2_function.function.name
233246
policy_data = data.google_iam_policy.foo.policy_data
234247
}
235248
`, context)
@@ -242,27 +255,20 @@ locals {
242255
project = "%{project}" # Google Cloud Platform Project ID
243256
}
244257
245-
provider "google-beta" {
246-
project = local.project
247-
}
248-
249258
resource "google_storage_bucket" "bucket" {
250-
provider = google-beta
251259
name = "${local.project}-tf-test-gcf-source%{random_suffix}" # Every bucket name must be globally unique
252260
location = "US"
253261
uniform_bucket_level_access = true
254262
}
255263
256264
resource "google_storage_bucket_object" "object" {
257-
provider = google-beta
258265
name = "function-source.zip"
259266
bucket = google_storage_bucket.bucket.name
260267
source = "%{zip_path}" # Add path to the zipped function source code
261268
}
262269
263270
resource "google_cloudfunctions2_function" "function" {
264-
provider = google-beta
265-
name = "tf-test-test-function%{random_suffix}"
271+
name = "tf-test-function-v2%{random_suffix}"
266272
location = "us-central1"
267273
description = "a new function"
268274
@@ -290,13 +296,12 @@ output "function_uri" {
290296
# [END functions_v2_basic]
291297
292298
data "google_iam_policy" "foo" {
293-
provider = google-beta
294299
}
295300
296301
resource "google_cloudfunctions2_function_iam_policy" "foo" {
297-
provider = google-beta
298-
cloud_function = google_cloudfunctions2_function.%{primary_resource_id}.name
299-
location = "%{location}"
302+
project = google_cloudfunctions2_function.function.project
303+
location = google_cloudfunctions2_function.function.location
304+
cloud_function = google_cloudfunctions2_function.function.name
300305
policy_data = data.google_iam_policy.foo.policy_data
301306
}
302307
`, context)
@@ -309,27 +314,20 @@ locals {
309314
project = "%{project}" # Google Cloud Platform Project ID
310315
}
311316
312-
provider "google-beta" {
313-
project = local.project
314-
}
315-
316317
resource "google_storage_bucket" "bucket" {
317-
provider = google-beta
318318
name = "${local.project}-tf-test-gcf-source%{random_suffix}" # Every bucket name must be globally unique
319319
location = "US"
320320
uniform_bucket_level_access = true
321321
}
322322
323323
resource "google_storage_bucket_object" "object" {
324-
provider = google-beta
325324
name = "function-source.zip"
326325
bucket = google_storage_bucket.bucket.name
327326
source = "%{zip_path}" # Add path to the zipped function source code
328327
}
329328
330329
resource "google_cloudfunctions2_function" "function" {
331-
provider = google-beta
332-
name = "tf-test-test-function%{random_suffix}"
330+
name = "tf-test-function-v2%{random_suffix}"
333331
location = "us-central1"
334332
description = "a new function"
335333
@@ -357,9 +355,9 @@ output "function_uri" {
357355
# [END functions_v2_basic]
358356
359357
resource "google_cloudfunctions2_function_iam_binding" "foo" {
360-
provider = google-beta
361-
cloud_function = google_cloudfunctions2_function.%{primary_resource_id}.name
362-
location = "%{location}"
358+
project = google_cloudfunctions2_function.function.project
359+
location = google_cloudfunctions2_function.function.location
360+
cloud_function = google_cloudfunctions2_function.function.name
363361
role = "%{role}"
364362
members = ["user:[email protected]"]
365363
}
@@ -373,27 +371,20 @@ locals {
373371
project = "%{project}" # Google Cloud Platform Project ID
374372
}
375373
376-
provider "google-beta" {
377-
project = local.project
378-
}
379-
380374
resource "google_storage_bucket" "bucket" {
381-
provider = google-beta
382375
name = "${local.project}-tf-test-gcf-source%{random_suffix}" # Every bucket name must be globally unique
383376
location = "US"
384377
uniform_bucket_level_access = true
385378
}
386379
387380
resource "google_storage_bucket_object" "object" {
388-
provider = google-beta
389381
name = "function-source.zip"
390382
bucket = google_storage_bucket.bucket.name
391383
source = "%{zip_path}" # Add path to the zipped function source code
392384
}
393385
394386
resource "google_cloudfunctions2_function" "function" {
395-
provider = google-beta
396-
name = "tf-test-test-function%{random_suffix}"
387+
name = "tf-test-function-v2%{random_suffix}"
397388
location = "us-central1"
398389
description = "a new function"
399390
@@ -421,9 +412,9 @@ output "function_uri" {
421412
# [END functions_v2_basic]
422413
423414
resource "google_cloudfunctions2_function_iam_binding" "foo" {
424-
provider = google-beta
425-
cloud_function = google_cloudfunctions2_function.%{primary_resource_id}.name
426-
location = "%{location}"
415+
project = google_cloudfunctions2_function.function.project
416+
location = google_cloudfunctions2_function.function.location
417+
cloud_function = google_cloudfunctions2_function.function.name
427418
role = "%{role}"
428419
members = ["user:[email protected]", "user:[email protected]"]
429420
}

0 commit comments

Comments
 (0)