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
…tion

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
slevenick authored and modular-magician committed Jan 17, 2020
1 parent cfbbb32 commit 4ce4a5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 7 additions & 0 deletions google-beta/resource_compute_instance_from_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ 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 != "" {
source, err := ParseDiskFieldValue(disk.Source, d, config)
if err != nil {
return nil, err
}
disk.Source = source.RelativeLink()
}
if disk.InitializeParams != nil {
if dt := disk.InitializeParams.DiskType; dt != "" {
// Instances need a URL for the disk type, but instance templates
Expand Down
18 changes: 10 additions & 8 deletions google-beta/resource_compute_instance_from_template_test.go
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 4ce4a5f

Please sign in to comment.