@@ -30,7 +30,7 @@ func TestAccCloudFunctions2Function_update(t *testing.T) {
30
30
ResourceName : "google_cloudfunctions2_function.terraform-test2" ,
31
31
ImportState : true ,
32
32
ImportStateVerify : true ,
33
- ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.bucket" , "labels" , "terraform_labels" },
33
+ ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.generation" , "build_config.0.source.0.storage_source.0. bucket" , "labels" , "terraform_labels" },
34
34
},
35
35
{
36
36
Config : testAccCloudFunctions2Function_test_update (context ),
@@ -39,7 +39,7 @@ func TestAccCloudFunctions2Function_update(t *testing.T) {
39
39
ResourceName : "google_cloudfunctions2_function.terraform-test2" ,
40
40
ImportState : true ,
41
41
ImportStateVerify : true ,
42
- ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.bucket" , "labels" , "terraform_labels" },
42
+ ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.generation" , "build_config.0.source.0.storage_source.0. bucket" , "labels" , "terraform_labels" },
43
43
},
44
44
{
45
45
Config : testAccCloudFunctions2Function_test_redeploy (context ),
@@ -48,7 +48,7 @@ func TestAccCloudFunctions2Function_update(t *testing.T) {
48
48
ResourceName : "google_cloudfunctions2_function.terraform-test2" ,
49
49
ImportState : true ,
50
50
ImportStateVerify : true ,
51
- ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.bucket" , "labels" , "terraform_labels" },
51
+ ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.generation" , "build_config.0.source.0.storage_source.0. bucket" , "labels" , "terraform_labels" },
52
52
},
53
53
},
54
54
})
@@ -117,7 +117,7 @@ resource "google_cloudfunctions2_function" "terraform-test2" {
117
117
labels = {
118
118
env = "test-update"
119
119
}
120
-
120
+
121
121
build_config {
122
122
runtime = "nodejs18"
123
123
entry_point = "helloHttp"
@@ -343,7 +343,7 @@ func TestAccCloudFunctions2Function_updateAbiuFull(t *testing.T) {
343
343
ResourceName : "google_cloudfunctions2_function.terraform-test2" ,
344
344
ImportState : true ,
345
345
ImportStateVerify : true ,
346
- ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.bucket" , "labels" , "terraform_labels" },
346
+ ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.generation" , "build_config.0.source.0.storage_source.0. bucket" , "labels" , "terraform_labels" },
347
347
},
348
348
{
349
349
Config : testAccCloudFunctions2Function_test_abiuUpdate (context ),
@@ -352,7 +352,7 @@ func TestAccCloudFunctions2Function_updateAbiuFull(t *testing.T) {
352
352
ResourceName : "google_cloudfunctions2_function.terraform-test2" ,
353
353
ImportState : true ,
354
354
ImportStateVerify : true ,
355
- ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.bucket" , "labels" , "terraform_labels" },
355
+ ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.generation" , "build_config.0.source.0.storage_source.0. bucket" , "labels" , "terraform_labels" },
356
356
},
357
357
{
358
358
Config : testAccCloudFunctions2Function_test_abiuUpdate2 (context ),
@@ -361,7 +361,7 @@ func TestAccCloudFunctions2Function_updateAbiuFull(t *testing.T) {
361
361
ResourceName : "google_cloudfunctions2_function.terraform-test2" ,
362
362
ImportState : true ,
363
363
ImportStateVerify : true ,
364
- ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.bucket" , "labels" , "terraform_labels" },
364
+ ImportStateVerifyIgnore : []string {"location" , "build_config.0.source.0.storage_source.0.object" , "build_config.0.source.0.storage_source.0.generation" , "build_config.0.source.0.storage_source.0. bucket" , "labels" , "terraform_labels" },
365
365
},
366
366
},
367
367
})
@@ -472,7 +472,7 @@ resource "google_cloudfunctions2_function" "terraform-test2" {
472
472
labels = {
473
473
env = "test-update"
474
474
}
475
-
475
+
476
476
build_config {
477
477
runtime = "nodejs18"
478
478
entry_point = "helloHttp"
@@ -490,3 +490,73 @@ resource "google_cloudfunctions2_function" "terraform-test2" {
490
490
}
491
491
` , context )
492
492
}
493
+
494
+ func TestAccCloudFunctions2Function_generation (t * testing.T ) {
495
+ t .Parallel ()
496
+
497
+ context := map [string ]interface {}{
498
+ "zip_path" : "./test-fixtures/function-source.zip" ,
499
+ "random_suffix" : acctest .RandString (t , 10 ),
500
+ }
501
+
502
+ acctest .VcrTest (t , resource.TestCase {
503
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
504
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
505
+ CheckDestroy : testAccCheckCloudfunctions2functionDestroyProducer (t ),
506
+ Steps : []resource.TestStep {
507
+ {
508
+ Config : testAccCloudfunctions2function_generation (context ),
509
+ Check : resource .ComposeTestCheckFunc (
510
+ resource .TestCheckOutput ("object_gen_eq_storage_source_gen" , "true" ),
511
+ ),
512
+ },
513
+ },
514
+ })
515
+ }
516
+
517
+ func testAccCloudfunctions2function_generation (context map [string ]interface {}) string {
518
+ return acctest .Nprintf (`
519
+ resource "google_storage_bucket" "bucket" {
520
+ name = "tf-test-cloudfunctions2-function-bucket%{random_suffix}"
521
+ location = "US"
522
+ uniform_bucket_level_access = true
523
+ }
524
+
525
+ resource "google_storage_bucket_object" "object" {
526
+ name = "function-source.zip"
527
+ bucket = google_storage_bucket.bucket.name
528
+ source = "%{zip_path}"
529
+ }
530
+
531
+ resource "google_cloudfunctions2_function" "terraform-test2" {
532
+ name = "tf-test-test-function%{random_suffix}"
533
+ location = "us-central1"
534
+ description = "a new function"
535
+ labels = {
536
+ env = "test"
537
+ }
538
+
539
+ build_config {
540
+ runtime = "nodejs18"
541
+ entry_point = "helloHttp"
542
+ source {
543
+ storage_source {
544
+ bucket = google_storage_bucket.bucket.name
545
+ object = google_storage_bucket_object.object.name
546
+ generation = google_storage_bucket_object.object.generation
547
+ }
548
+ }
549
+ }
550
+
551
+ service_config {
552
+ max_instance_count = 1
553
+ available_memory = "1536Mi"
554
+ timeout_seconds = 30
555
+ }
556
+ }
557
+
558
+ output "object_gen_eq_storage_source_gen" {
559
+ value = google_storage_bucket_object.object.generation == google_cloudfunctions2_function.terraform-test2.build_config.0.source.0.storage_source.0.generation
560
+ }
561
+ ` , context )
562
+ }
0 commit comments