@@ -835,7 +835,22 @@ func TestAccComputeInstance_with375GbScratchDisk(t *testing.T) {
835
835
Check : resource .ComposeTestCheckFunc (
836
836
testAccCheckComputeInstanceExists (
837
837
t , "google_compute_instance.foobar" , & instance ),
838
- testAccCheckComputeInstanceScratchDisk (& instance , []string {"NVME" , "SCSI" }),
838
+ testAccCheckComputeInstanceScratchDisk (& instance , []map [string ]string {
839
+ {
840
+ "interface" : "NVME" ,
841
+ },
842
+ {
843
+ "interface" : "SCSI" ,
844
+ },
845
+ {
846
+ "interface" : "NVME" ,
847
+ "deviceName" : "nvme-local-ssd" ,
848
+ },
849
+ {
850
+ "interface" : "SCSI" ,
851
+ "deviceName" : "scsi-local-ssd" ,
852
+ },
853
+ }),
839
854
),
840
855
},
841
856
computeInstanceImportStep ("us-central1-a" , instanceName , []string {}),
@@ -862,7 +877,26 @@ func TestAccComputeInstance_with18TbScratchDisk(t *testing.T) {
862
877
Check : resource .ComposeTestCheckFunc (
863
878
testAccCheckComputeInstanceExists (
864
879
t , "google_compute_instance.foobar" , & instance ),
865
- testAccCheckComputeInstanceScratchDisk (& instance , []string {"NVME" , "NVME" , "NVME" , "NVME" , "NVME" , "NVME" }),
880
+ testAccCheckComputeInstanceScratchDisk (& instance , []map [string ]string {
881
+ {
882
+ "interface" : "NVME" ,
883
+ },
884
+ {
885
+ "interface" : "NVME" ,
886
+ },
887
+ {
888
+ "interface" : "NVME" ,
889
+ },
890
+ {
891
+ "interface" : "NVME" ,
892
+ },
893
+ {
894
+ "interface" : "NVME" ,
895
+ },
896
+ {
897
+ "interface" : "NVME" ,
898
+ },
899
+ }),
866
900
),
867
901
},
868
902
computeInstanceImportStep ("us-central1-a" , instanceName , []string {}),
@@ -2820,7 +2854,7 @@ func testAccCheckComputeInstanceBootDiskType(t *testing.T, instanceName string,
2820
2854
}
2821
2855
}
2822
2856
2823
- func testAccCheckComputeInstanceScratchDisk (instance * compute.Instance , interfaces []string ) resource.TestCheckFunc {
2857
+ func testAccCheckComputeInstanceScratchDisk (instance * compute.Instance , interfaces []map [ string ] string ) resource.TestCheckFunc {
2824
2858
return func (s * terraform.State ) error {
2825
2859
if instance .Disks == nil {
2826
2860
return fmt .Errorf ("no disks" )
@@ -2832,10 +2866,17 @@ func testAccCheckComputeInstanceScratchDisk(instance *compute.Instance, interfac
2832
2866
if i >= len (interfaces ) {
2833
2867
return fmt .Errorf ("Expected %d scratch disks, found more" , len (interfaces ))
2834
2868
}
2835
- if disk .Interface != interfaces [i ] {
2869
+ if disk .Interface != interfaces [i ][ "interface" ] {
2836
2870
return fmt .Errorf ("Mismatched interface on scratch disk #%d, expected: %q, found: %q" ,
2837
2871
i , interfaces [i ], disk .Interface )
2838
2872
}
2873
+ if deviceName , ok := interfaces [i ]["deviceName" ]; ok {
2874
+ if disk .DeviceName != deviceName {
2875
+ return fmt .Errorf ("Mismatched device name on scratch disk #%d, expected: %q, found: %q" ,
2876
+ i , deviceName , disk .DeviceName )
2877
+ }
2878
+ }
2879
+
2839
2880
i ++
2840
2881
}
2841
2882
}
@@ -4729,6 +4770,16 @@ resource "google_compute_instance" "foobar" {
4729
4770
interface = "SCSI"
4730
4771
}
4731
4772
4773
+ scratch_disk {
4774
+ interface = "NVME"
4775
+ device_name = "nvme-local-ssd"
4776
+ }
4777
+
4778
+ scratch_disk {
4779
+ interface = "SCSI"
4780
+ device_name = "scsi-local-ssd"
4781
+ }
4782
+
4732
4783
network_interface {
4733
4784
network = "default"
4734
4785
}
0 commit comments