@@ -550,6 +550,42 @@ func TestAccComputeDisk_encryptionKMS(t *testing.T) {
550550 })
551551}
552552
553+ func TestAccComputeDisk_pdHyperDiskEnableConfidentialCompute (t * testing.T ) {
554+ t .Skip ()
555+ t .Parallel ()
556+
557+ context := map [string ]interface {}{
558+ "random_suffix" : acctest .RandString (t , 10 ),
559+ "kms" : acctest .BootstrapKMSKey (t ).CryptoKey .Name , // global KMS key
560+ "disk_size" : 64 ,
561+ "confidential_compute" : true ,
562+ }
563+
564+ var disk compute.Disk
565+
566+ VcrTest (t , resource.TestCase {
567+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
568+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
569+ CheckDestroy : testAccCheckComputeDiskDestroyProducer (t ),
570+ Steps : []resource.TestStep {
571+ {
572+ Config : testAccComputeDisk_pdHyperDiskEnableConfidentialCompute (context ),
573+ Check : resource .ComposeTestCheckFunc (
574+ testAccCheckComputeDiskExists (
575+ t , "google_compute_disk.foobar" , envvar .GetTestProjectFromEnv (), & disk ),
576+ testAccCheckEncryptionKey (
577+ t , "google_compute_disk.foobar" , & disk ),
578+ ),
579+ },
580+ {
581+ ResourceName : "google_compute_disk.foobar" ,
582+ ImportState : true ,
583+ ImportStateVerify : true ,
584+ },
585+ },
586+ })
587+ }
588+
553589func TestAccComputeDisk_deleteDetach (t * testing.T ) {
554590 t .Parallel ()
555591
@@ -662,6 +698,49 @@ func TestAccComputeDisk_pdExtremeImplicitProvisionedIops(t *testing.T) {
662698 })
663699}
664700
701+ func TestAccComputeDisk_resourcePolicies (t * testing.T ) {
702+ t .Parallel ()
703+
704+ diskName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 ))
705+ policyName := fmt .Sprintf ("tf-test-policy-%s" , acctest .RandString (t , 10 ))
706+
707+ acctest .VcrTest (t , resource.TestCase {
708+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
709+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
710+ Steps : []resource.TestStep {
711+ {
712+ Config : testAccComputeDisk_resourcePolicies (diskName , policyName ),
713+ },
714+ {
715+ ResourceName : "google_compute_disk.foobar" ,
716+ ImportState : true ,
717+ ImportStateVerify : true ,
718+ },
719+ },
720+ })
721+ }
722+
723+ func TestAccComputeDisk_multiWriter (t * testing.T ) {
724+ t .Parallel ()
725+ instanceName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 ))
726+ diskName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 ))
727+
728+ acctest .VcrTest (t , resource.TestCase {
729+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
730+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
731+ Steps : []resource.TestStep {
732+ {
733+ Config : testAccComputeDisk_multiWriter (instanceName , diskName , true ),
734+ },
735+ {
736+ ResourceName : "google_compute_disk.foobar" ,
737+ ImportState : true ,
738+ ImportStateVerify : true ,
739+ },
740+ },
741+ })
742+ }
743+
665744func testAccCheckComputeDiskExists (t * testing.T , n , p string , disk * compute.Disk ) resource.TestCheckFunc {
666745 return func (s * terraform.State ) error {
667746 rs , ok := s .RootModule ().Resources [n ]
@@ -1029,6 +1108,80 @@ resource "google_compute_disk" "foobar" {
10291108` , diskName )
10301109}
10311110
1111+ func testAccComputeDisk_resourcePolicies (diskName , policyName string ) string {
1112+ return fmt .Sprintf (`
1113+ data "google_compute_image" "my_image" {
1114+ family = "debian-11"
1115+ project = "debian-cloud"
1116+ }
1117+
1118+ resource "google_compute_resource_policy" "foo" {
1119+ name = "%s"
1120+ region = "us-central1"
1121+ snapshot_schedule_policy {
1122+ schedule {
1123+ daily_schedule {
1124+ days_in_cycle = 1
1125+ start_time = "04:00"
1126+ }
1127+ }
1128+ }
1129+ }
1130+
1131+ resource "google_compute_disk" "foobar" {
1132+ name = "%s"
1133+ image = data.google_compute_image.my_image.self_link
1134+ size = 50
1135+ type = "pd-ssd"
1136+ zone = "us-central1-a"
1137+ resource_policies = [google_compute_resource_policy.foo.self_link]
1138+ }
1139+ ` , policyName , diskName )
1140+ }
1141+
1142+ func testAccComputeDisk_multiWriter (instance string , diskName string , enableMultiwriter bool ) string {
1143+ return fmt .Sprintf (`
1144+ data "google_compute_image" "my_image" {
1145+ family = "debian-11"
1146+ project = "debian-cloud"
1147+ }
1148+
1149+ resource "google_compute_disk" "foobar" {
1150+ name = "%s"
1151+ size = 10
1152+ type = "pd-ssd"
1153+ zone = "us-central1-a"
1154+ multi_writer = %t
1155+ }
1156+
1157+ resource "google_compute_instance" "foobar" {
1158+ name = "%s"
1159+ machine_type = "n2-standard-2"
1160+ zone = "us-central1-a"
1161+ can_ip_forward = false
1162+ tags = ["foo", "bar"]
1163+
1164+ boot_disk {
1165+ initialize_params {
1166+ image = data.google_compute_image.my_image.self_link
1167+ }
1168+ }
1169+
1170+ attached_disk {
1171+ source = google_compute_disk.foobar.name
1172+ }
1173+
1174+ network_interface {
1175+ network = "default"
1176+ }
1177+
1178+ metadata = {
1179+ foo = "bar"
1180+ }
1181+ }
1182+ ` , diskName , enableMultiwriter , instance )
1183+ }
1184+
10321185func testAccComputeDisk_diskClone (diskName , refSelector string ) string {
10331186 return fmt .Sprintf (`
10341187 data "google_compute_image" "my_image" {
0 commit comments