@@ -36,6 +36,43 @@ func TestAccSpannerInstance_basic(t *testing.T) {
36
36
})
37
37
}
38
38
39
+ func TestAccSpannerInstance_basicUpdateWithProviderDefaultLabels (t * testing.T ) {
40
+ t .Parallel ()
41
+
42
+ idName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 ))
43
+ acctest .VcrTest (t , resource.TestCase {
44
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
45
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
46
+ CheckDestroy : testAccCheckSpannerInstanceDestroyProducer (t ),
47
+ Steps : []resource.TestStep {
48
+ {
49
+ Config : testAccSpannerInstance_basicWithProviderLabel (idName , false ),
50
+ Check : resource .ComposeTestCheckFunc (
51
+ resource .TestCheckResourceAttrSet ("google_spanner_instance.basic" , "state" ),
52
+ ),
53
+ },
54
+ {
55
+ ResourceName : "google_spanner_instance.basic" ,
56
+ ImportState : true ,
57
+ ImportStateVerify : true ,
58
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
59
+ },
60
+ {
61
+ Config : testAccSpannerInstance_basicWithProviderLabel (idName , true ),
62
+ Check : resource .ComposeTestCheckFunc (
63
+ resource .TestCheckResourceAttrSet ("google_spanner_instance.basic" , "state" ),
64
+ ),
65
+ },
66
+ {
67
+ ResourceName : "google_spanner_instance.basic" ,
68
+ ImportState : true ,
69
+ ImportStateVerify : true ,
70
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
71
+ },
72
+ },
73
+ })
74
+ }
75
+
39
76
func TestAccSpannerInstance_noNodeCountSpecified (t * testing.T ) {
40
77
t .Parallel ()
41
78
@@ -400,6 +437,62 @@ resource "google_spanner_instance" "basic" {
400
437
` , name , name )
401
438
}
402
439
440
+ func testAccSpannerInstance_basicWithProviderLabel (name string , addLabel bool ) string {
441
+ extraLabel := ""
442
+ if addLabel {
443
+ extraLabel = "\" key2\" = \" value2\" "
444
+ }
445
+ return fmt .Sprintf (`
446
+ provider "google" {
447
+ alias = "with-labels"
448
+ default_labels = {
449
+ %s
450
+ }
451
+ }
452
+
453
+ resource "google_spanner_instance" "basic" {
454
+ provider = google.with-labels
455
+ config = "regional-us-central1"
456
+ name = "%s"
457
+ display_name = "%s"
458
+
459
+ processing_units = 100
460
+
461
+ labels = {
462
+ "key1" = "value1"
463
+ }
464
+ }
465
+ ` , extraLabel , name , name )
466
+ }
467
+
468
+ func testAccSpannerInstance_basicWithNodes (name string , nodes int ) string {
469
+ return fmt .Sprintf (`
470
+ resource "google_spanner_instance" "basic" {
471
+ name = "%s"
472
+ config = "regional-us-central1"
473
+ display_name = "%s-dname"
474
+
475
+ num_nodes = %d
476
+ edition = "ENTERPRISE"
477
+ default_backup_schedule_type = "NONE"
478
+ }
479
+ ` , name , name , nodes )
480
+ }
481
+
482
+ func testAccSpannerInstance_basicWithProcessingUnits (name string , processingUnits int ) string {
483
+ return fmt .Sprintf (`
484
+ resource "google_spanner_instance" "basic" {
485
+ name = "%s"
486
+ config = "regional-us-central1"
487
+ display_name = "%s-dname"
488
+
489
+ processing_units = %d
490
+ edition = "ENTERPRISE"
491
+ default_backup_schedule_type = "NONE"
492
+ }
493
+ ` , name , name , processingUnits )
494
+ }
495
+
403
496
func testAccSpannerInstance_noNodeCountSpecified (name string ) string {
404
497
return fmt .Sprintf (`
405
498
resource "google_spanner_instance" "basic" {
0 commit comments