@@ -3514,6 +3514,56 @@ func TestAccComputeInstance_proactiveAttributionLabel(t *testing.T) {
3514
3514
})
3515
3515
}
3516
3516
3517
+ func TestAccComputeInstance_keyRevocationActionType (t * testing.T ) {
3518
+ t .Parallel ()
3519
+
3520
+ var instance compute.Instance
3521
+ context_1 := map [string ]interface {}{
3522
+ "instance_name" : fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 )),
3523
+ "key_revocation_action_type" : `"NONE"` ,
3524
+ }
3525
+ context_2 := map [string ]interface {}{
3526
+ "instance_name" : context_1 ["instance_name" ].(string ),
3527
+ "key_revocation_action_type" : `"STOP"` ,
3528
+ }
3529
+ context_3 := map [string ]interface {}{
3530
+ "instance_name" : context_1 ["instance_name" ].(string ),
3531
+ "key_revocation_action_type" : `""` ,
3532
+ }
3533
+
3534
+ acctest .VcrTest (t , resource.TestCase {
3535
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
3536
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
3537
+ CheckDestroy : testAccCheckComputeInstanceDestroyProducer (t ),
3538
+ Steps : []resource.TestStep {
3539
+ {
3540
+ Config : testAccComputeInstance_keyRevocationActionType (context_1 ),
3541
+ Check : resource .ComposeTestCheckFunc (
3542
+ testAccCheckComputeInstanceExists (
3543
+ t , "google_compute_instance.foobar" , & instance ),
3544
+ resource .TestCheckResourceAttr ("google_compute_instance.foobar" , "key_revocation_action_type" , "NONE" ),
3545
+ ),
3546
+ },
3547
+ {
3548
+ Config : testAccComputeInstance_keyRevocationActionType (context_2 ),
3549
+ Check : resource .ComposeTestCheckFunc (
3550
+ testAccCheckComputeInstanceExists (
3551
+ t , "google_compute_instance.foobar" , & instance ),
3552
+ resource .TestCheckResourceAttr ("google_compute_instance.foobar" , "key_revocation_action_type" , "STOP" ),
3553
+ ),
3554
+ },
3555
+ {
3556
+ Config : testAccComputeInstance_keyRevocationActionType (context_3 ),
3557
+ Check : resource .ComposeTestCheckFunc (
3558
+ testAccCheckComputeInstanceExists (
3559
+ t , "google_compute_instance.foobar" , & instance ),
3560
+ resource .TestCheckResourceAttr ("google_compute_instance.foobar" , "key_revocation_action_type" , "" ),
3561
+ ),
3562
+ },
3563
+ },
3564
+ })
3565
+ }
3566
+
3517
3567
const errorDeleteAccessConfigWithSecPolicy = "Cannot delete an access config with a security policy set. Please remove the security policy first"
3518
3568
3519
3569
// The tests related to security_policy use network_edge_security_service resource
@@ -10789,3 +10839,30 @@ resource "google_compute_instance" "foobar" {
10789
10839
}
10790
10840
` , diskName , instanceName , machineType , zone , bootDiskInterface , allowStoppingForUpdate )
10791
10841
}
10842
+
10843
+ func testAccComputeInstance_keyRevocationActionType (context map [string ]interface {}) string {
10844
+ return acctest .Nprintf (`
10845
+ data "google_compute_image" "my_image" {
10846
+ family = "debian-11"
10847
+ project = "debian-cloud"
10848
+ }
10849
+
10850
+ resource "google_compute_instance" "foobar" {
10851
+ name = "%{instance_name}"
10852
+ machine_type = "e2-medium"
10853
+ zone = "us-central1-a"
10854
+
10855
+ boot_disk {
10856
+ initialize_params {
10857
+ image = data.google_compute_image.my_image.self_link
10858
+ }
10859
+ }
10860
+
10861
+ network_interface {
10862
+ network = "default"
10863
+ }
10864
+
10865
+ key_revocation_action_type = %{key_revocation_action_type}
10866
+ }
10867
+ ` , context )
10868
+ }
0 commit comments