@@ -45,7 +45,8 @@ resource "google_compute_instance_template" "default" {
45
45
46
46
// Use an existing disk resource
47
47
disk {
48
- source = "foo_existing_disk"
48
+ // Instance Templates reference disks by name, not self link
49
+ source = "${google_compute_disk.foobar.name}"
49
50
auto_delete = false
50
51
boot = false
51
52
}
@@ -62,6 +63,19 @@ resource "google_compute_instance_template" "default" {
62
63
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
63
64
}
64
65
}
66
+
67
+ data "google_compute_image" "my_image" {
68
+ family = "debian-9"
69
+ project = "debian-cloud"
70
+ }
71
+
72
+ resource "google_compute_disk" "foobar" {
73
+ name = "existing-disk"
74
+ image = "${data.google_compute_image.my_image.self_link}"
75
+ size = 10
76
+ type = "pd-ssd"
77
+ zone = "us-central1-a"
78
+ }
65
79
```
66
80
67
81
## Using with Instance Group Manager
@@ -260,9 +274,8 @@ The `disk` block supports:
260
274
or READ_ONLY. If you are attaching or creating a boot disk, this must
261
275
read-write mode.
262
276
263
- * ` source ` - (Required if source_image not set) The name of the disk (such as
264
- those managed by ` google_compute_disk ` ) to attach. This cannot be a regional
265
- disk.
277
+ * ` source ` - (Required if source_image not set) The name (** not self_link** )
278
+ of the disk (such as those managed by ` google_compute_disk ` ) to attach.
266
279
267
280
* ` disk_type ` - (Optional) The GCE disk type. Can be either ` "pd-ssd" ` ,
268
281
` "local-ssd" ` , or ` "pd-standard" ` .
0 commit comments