Skip to content

Commit

Permalink
Expand boot disk name to full name during instance from template crea…
Browse files Browse the repository at this point in the history
  • Loading branch information
slevenick authored and Nathan Klish committed May 18, 2020
1 parent 5ae6965 commit 670040e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func adjustInstanceFromTemplateDisks(d *schema.ResourceData, config *Config, it
// boot disk was not overridden, so use the one from the instance template
for _, disk := range it.Properties.Disks {
if disk.Boot {
if disk.Source != "" {
// Instances need a URL for the disk, but instance templates only have the name
disk.Source = fmt.Sprintf("projects/%s/zones/%s/disks/%s", project, zone.Name, disk.Source)
}
if disk.InitializeParams != nil {
if dt := disk.InitializeParams.DiskType; dt != "" {
// Instances need a URL for the disk type, but instance templates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,10 @@ resource "google_compute_instance_template" "foobar" {
name = "%s"
machine_type = "n1-standard-1"
disk {
source_image = data.google_compute_image.my_image.self_link
auto_delete = true
disk_size_gb = 100
boot = true
}
disk {
source = google_compute_disk.foobar.name
auto_delete = false
boot = false
boot = true
}
disk {
Expand All @@ -249,6 +242,15 @@ resource "google_compute_instance_template" "foobar" {
disk_size_gb = 375
}
disk {
source_image = data.google_compute_image.my_image.self_link
auto_delete = true
disk_size_gb = 100
boot = false
disk_type = "pd-ssd"
type = "PERSISTENT"
}
network_interface {
network = "default"
}
Expand Down

0 comments on commit 670040e

Please sign in to comment.