packer-plugin-googlecompute icon indicating copy to clipboard operation
packer-plugin-googlecompute copied to clipboard

Add `source_image` to `disk_attachment`

Open adsr opened this issue 2 years ago • 6 comments

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.

adsr avatar Oct 30 '23 21:10 adsr

CLA assistant check
All committers have signed the CLA.

hashicorp-cla avatar Oct 30 '23 21:10 hashicorp-cla

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 avatar Nov 08 '23 18:11 adsr

~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 avatar Nov 08 '23 20:11 adsr

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?

nywilken avatar Apr 15 '24 14:04 nywilken

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 🙏

uriyyo avatar Jun 06 '24 13:06 uriyyo

Hey @lbajolet-hashicorp, I've merged the latest changes from main into this branch (I work with @adsr). Mind taking another look?

ericnorris avatar Jan 08 '25 22:01 ericnorris

FYI @adsr @ericnorris , I've force-pushed a commit on top of @adsr's original branch to have only one commit to merge and to fold-in a fix on an attribute's name (zone vs. Zone) which had been changed between the original PR and now. If tests go green with this, we can merge this right after.

lbajolet-hashicorp avatar Jan 24 '25 16:01 lbajolet-hashicorp

Thanks for taking a look and making that fix, sorry I missed it haha.

ericnorris avatar Jan 24 '25 16:01 ericnorris

@lbajolet-hashicorp @JenGoldstrich thanks again for merging this! Are you planning on cutting a release that incorporates this soon?

ericnorris avatar Jan 27 '25 16:01 ericnorris