@@ -3664,6 +3664,49 @@ func TestAccComputeInstance_proactiveAttributionLabel(t *testing.T) {
3664
3664
})
3665
3665
}
3666
3666
3667
+ func TestAccComputeInstance_autoDeleteUpdate(t *testing.T) {
3668
+ t.Parallel()
3669
+
3670
+ var instance compute.Instance
3671
+ context_1 := map[string]interface{}{
3672
+ "instance_name": fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)),
3673
+ "auto_delete": "true",
3674
+ }
3675
+ context_2 := map[string]interface{}{
3676
+ "instance_name": context_1["instance_name"],
3677
+ "auto_delete": "false",
3678
+ }
3679
+
3680
+ acctest.VcrTest(t, resource.TestCase{
3681
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
3682
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
3683
+ CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
3684
+ Steps: []resource.TestStep{
3685
+ {
3686
+ Config: testAccComputeInstance_autoDeleteUpdate(context_1),
3687
+ Check: resource.ComposeTestCheckFunc(
3688
+ testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
3689
+ resource.TestCheckResourceAttr("google_compute_instance.foobar", "boot_disk.0.auto_delete", "true"),
3690
+ ),
3691
+ },
3692
+ {
3693
+ Config: testAccComputeInstance_autoDeleteUpdate(context_2),
3694
+ Check: resource.ComposeTestCheckFunc(
3695
+ testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
3696
+ resource.TestCheckResourceAttr("google_compute_instance.foobar", "boot_disk.0.auto_delete", "false"),
3697
+ ),
3698
+ },
3699
+ {
3700
+ Config: testAccComputeInstance_autoDeleteUpdate(context_1),
3701
+ Check: resource.ComposeTestCheckFunc(
3702
+ testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
3703
+ resource.TestCheckResourceAttr("google_compute_instance.foobar", "boot_disk.0.auto_delete", "true"),
3704
+ ),
3705
+ },
3706
+ },
3707
+ })
3708
+ }
3709
+
3667
3710
func TestAccComputeInstance_keyRevocationActionType(t *testing.T) {
3668
3711
t.Parallel()
3669
3712
@@ -11117,29 +11160,55 @@ resource "google_compute_instance" "foobar" {
11117
11160
`, diskName, instanceName, machineType, zone, bootDiskInterface, allowStoppingForUpdate)
11118
11161
}
11119
11162
11163
+ func testAccComputeInstance_autoDeleteUpdate(context map[string]interface{}) string {
11164
+ return acctest.Nprintf(`
11165
+ data "google_compute_image" "my_image" {
11166
+ family = "debian-11"
11167
+ project = "debian-cloud"
11168
+ }
11169
+
11170
+ resource "google_compute_instance" "foobar" {
11171
+ name = "%{instance_name}"
11172
+ machine_type = "n1-standard-1"
11173
+ zone = "us-central1-a"
11174
+
11175
+ boot_disk {
11176
+ auto_delete = %{auto_delete}
11177
+ initialize_params {
11178
+ image = data.google_compute_image.my_image.self_link
11179
+ }
11180
+ }
11181
+
11182
+ network_interface {
11183
+ network = "default"
11184
+ }
11185
+ }
11186
+ `, context)
11187
+ }
11188
+
11120
11189
func testAccComputeInstance_keyRevocationActionType(context map[string]interface{}) string {
11121
11190
return acctest.Nprintf(`
11122
11191
data "google_compute_image" "my_image" {
11123
- family = "debian-11"
11124
- project = "debian-cloud"
11192
+ family = "debian-11"
11193
+ project = "debian-cloud"
11125
11194
}
11126
11195
11127
11196
resource "google_compute_instance" "foobar" {
11128
- name = "%{instance_name}"
11129
- machine_type = "e2-medium"
11130
- zone = "us-central1-a"
11197
+ name = "%{instance_name}"
11198
+ machine_type = "e2-medium"
11199
+ zone = "us-central1-a"
11131
11200
11132
- boot_disk {
11201
+ boot_disk {
11133
11202
initialize_params {
11134
- image = data.google_compute_image.my_image.self_link
11203
+ image = data.google_compute_image.my_image.self_link
11204
+ }
11135
11205
}
11136
- }
11137
11206
11138
- network_interface {
11139
- network = "default"
11140
- }
11207
+ network_interface {
11208
+ network = "default"
11209
+ }
11141
11210
11142
- key_revocation_action_type = %{key_revocation_action_type}
11211
+ key_revocation_action_type = %{key_revocation_action_type}
11143
11212
}
11144
11213
`, context)
11145
11214
}
0 commit comments