hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
23 stars 51 forks source link

Add `source_image` to `disk_attachment` #196

Open adsr opened 8 months ago

adsr commented 8 months ago

Add ability to specify a source_image in a disk_attachment.

Relevant excerpt from GCP godocs:

    // SourceImage: The source image to create this disk. When creating a
    // new instance, one of initializeParams.sourceImage or
    // initializeParams.sourceSnapshot or disks.source is required except
    // for local SSD.
hashicorp-cla commented 8 months ago

CLA assistant check
All committers have signed the CLA.

adsr commented 8 months ago

Here's a barebones template that illustrates what we're going for.

source "googlecompute" "image_extra_disk" {
  project_id = var.gcp_project_id
  zone = var.gcp_zone

  source_image_family = var.source_image_family

  image_name = var.image_name

  disk_attachment {                     
    disk_name = "extra-disk"                                
    device_name = "extra_disk"
    source_image = var.extra_disk_source_image_family
    volume_type = "pd-standard"
  }                   

  image_source_disk = "extra-disk"
}
adsr commented 8 months ago

~I've noticed it's actually creating 3 disks, the boot disk, an extra disk, and then a 3rd disk with the image. Need to fix this up. Converted to draft for now.~

EDIT: Force-pushed to 689fc55. Now creating just 2 just disks as expected.

adsr commented 7 months ago

Ran goimports and gofmt

nywilken commented 2 months ago

Hi @adsr thanks for your help in pushing this enhancement forward. It looks like there were just a few suggestions left to address with a rebase to resolve conflicts.

Are you still interested in pushing this PR forward?

uriyyo commented 4 weeks ago

Hi @adsr @lbajolet-hashicorp,

We would like to use this feature in our project. Is there smth we can help with? In case we are stuck with this PR, we can open an alternative PR with this feature.

Please, let me know if there is smth we can help with 🙏