@@ -68,6 +68,33 @@ func TestAccComputeAttachedDisk_full(t *testing.T) {
68
68
69
69
}
70
70
71
+ func TestAccComputeAttachedDisk_region (t * testing.T ) {
72
+ t .Parallel ()
73
+
74
+ diskName := acctest .RandomWithPrefix ("tf-test" )
75
+ instanceName := acctest .RandomWithPrefix ("tf-test" )
76
+ importID := fmt .Sprintf ("%s/us-central1-a/%s:%s" , getTestProjectFromEnv (), instanceName , diskName )
77
+
78
+ resource .Test (t , resource.TestCase {
79
+ PreCheck : func () { testAccPreCheck (t ) },
80
+ Providers : testAccProviders ,
81
+ // Check destroy isn't a good test here, see comment on testCheckAttachedDiskIsNowDetached
82
+ CheckDestroy : nil ,
83
+ Steps : []resource.TestStep {
84
+ resource.TestStep {
85
+ Config : testAttachedDiskResource_region (diskName , instanceName ),
86
+ },
87
+ resource.TestStep {
88
+ ResourceName : "google_compute_attached_disk.test" ,
89
+ ImportStateId : importID ,
90
+ ImportState : true ,
91
+ ImportStateVerify : true ,
92
+ },
93
+ },
94
+ })
95
+
96
+ }
97
+
71
98
func TestAccComputeAttachedDisk_count (t * testing.T ) {
72
99
t .Parallel ()
73
100
@@ -152,6 +179,43 @@ resource "google_compute_attached_disk" "test" {
152
179
}` )
153
180
}
154
181
182
+ func testAttachedDiskResource_region (diskName , instanceName string ) string {
183
+ return fmt .Sprintf (`
184
+ resource "google_compute_attached_disk" "test" {
185
+ disk = "${google_compute_region_disk.region.self_link}"
186
+ instance = "${google_compute_instance.test.self_link}"
187
+ }
188
+
189
+ resource "google_compute_region_disk" "region" {
190
+ name = "%s"
191
+ region = "us-central1"
192
+ size = 10
193
+ replica_zones = ["us-central1-b", "us-central1-a"]
194
+ }
195
+
196
+ resource "google_compute_instance" "test" {
197
+ name = "%s"
198
+ machine_type = "f1-micro"
199
+ zone = "us-central1-a"
200
+
201
+ lifecycle {
202
+ ignore_changes = [
203
+ "attached_disk",
204
+ ]
205
+ }
206
+
207
+ boot_disk {
208
+ initialize_params {
209
+ image = "debian-cloud/debian-9"
210
+ }
211
+ }
212
+
213
+ network_interface {
214
+ network = "default"
215
+ }
216
+ }` , diskName , instanceName )
217
+ }
218
+
155
219
func testAttachedDiskResource (diskName , instanceName string ) string {
156
220
return fmt .Sprintf (`
157
221
resource "google_compute_disk" "test1" {
0 commit comments