@@ -2789,6 +2789,33 @@ func testAccCheckComputeInstanceUpdateMachineType(t *testing.T, n string) resour
2789
2789
}
2790
2790
}
2791
2791
2792
+ func TestAccComputeInstance_NicStackTypeUpdate (t * testing.T ) {
2793
+ t .Parallel ()
2794
+ suffix := acctest .RandString (t , 10 )
2795
+ envRegion := envvar .GetTestRegionFromEnv ()
2796
+ instanceName := fmt .Sprintf ("tf-test-compute-instance-%s" , suffix )
2797
+
2798
+ acctest .VcrTest (t , resource.TestCase {
2799
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
2800
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
2801
+ CheckDestroy : testAccCheckComputeInstanceDestroyProducer (t ),
2802
+ Steps : []resource.TestStep {
2803
+ {
2804
+ Config : testAccComputeInstance_nicStackTypeUpdate (suffix , envRegion , "IPV4_ONLY" , instanceName ),
2805
+ },
2806
+ computeInstanceImportStep ("us-central1-a" , instanceName , []string {"allow_stopping_for_update" }),
2807
+ {
2808
+ Config : testAccComputeInstance_nicStackTypeUpdate (suffix , envRegion , "IPV4_IPV6" , instanceName ),
2809
+ },
2810
+ computeInstanceImportStep ("us-central1-a" , instanceName , []string {"allow_stopping_for_update" }),
2811
+ {
2812
+ Config : testAccComputeInstance_nicStackTypeUpdate (suffix , envRegion , "IPV4_ONLY" , instanceName ),
2813
+ },
2814
+ computeInstanceImportStep ("us-central1-a" , instanceName , []string {"allow_stopping_for_update" }),
2815
+ },
2816
+ })
2817
+ }
2818
+
2792
2819
func testAccCheckComputeInstanceDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
2793
2820
return func (s * terraform.State ) error {
2794
2821
config := acctest .GoogleProviderConfig (t )
@@ -7355,3 +7382,51 @@ resource "google_compute_disk" "debian" {
7355
7382
}
7356
7383
` , instance , diskName , suffix , suffix , suffix )
7357
7384
}
7385
+
7386
+ func testAccComputeInstance_nicStackTypeUpdate (suffix , region , stack_type , instance string ) string {
7387
+ return fmt .Sprintf (`
7388
+ data "google_compute_image" "my_image" {
7389
+ family = "debian-11"
7390
+ project = "debian-cloud"
7391
+ }
7392
+
7393
+ resource "google_compute_network" "net" {
7394
+ name = "tf-test-network-%s"
7395
+ enable_ula_internal_ipv6 = true
7396
+ auto_create_subnetworks = false
7397
+ }
7398
+
7399
+ resource "google_compute_subnetwork" "subnet-ipv6" {
7400
+ region = "%s"
7401
+ name = "tf-test-subnet-ip6-%s"
7402
+ ip_cidr_range = "10.0.0.0/22"
7403
+ purpose = "PRIVATE"
7404
+ stack_type = "IPV4_IPV6"
7405
+ ipv6_access_type = "INTERNAL"
7406
+ network = google_compute_network.net.id
7407
+ }
7408
+
7409
+ resource "google_compute_instance" "foobar" {
7410
+ name = "%s"
7411
+ machine_type = "e2-medium"
7412
+ zone = "%s-a"
7413
+ tags = ["foo", "bar"]
7414
+
7415
+ boot_disk {
7416
+ initialize_params {
7417
+ image = data.google_compute_image.my_image.self_link
7418
+ }
7419
+ }
7420
+
7421
+ network_interface {
7422
+ network = google_compute_network.net.self_link
7423
+ subnetwork = google_compute_subnetwork.subnet-ipv6.self_link
7424
+ stack_type = "%s"
7425
+ }
7426
+
7427
+ metadata = {
7428
+ foo = "bar"
7429
+ }
7430
+ }
7431
+ ` , suffix , region , suffix , instance , region , stack_type )
7432
+ }
0 commit comments