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

amazon-import post-processor handles multiple disks improperly

Open ghost opened this issue 4 years ago • 2 comments

This issue was originally opened by @benjamb as hashicorp/packer#8590. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

In my case, I'm using the hyperv-iso builder and have entries within disk_additional_size, when this is passed on to the amazon-import post-processor it ends up finding the wrong disk.

The code in question isn't particularly smart. It iterates over artefacts from a builder and returns the first artefact it finds that has the specified suffix (in my case vhdx). The issue with this, on Windows at least, is that vm-0.vhdx is found before the core image without the index suffix, i.e. vm.vhdx when iterating over the artefacts.

for _, path := range artifact.Files() {
	if strings.HasSuffix(path, "."+p.config.Format) {
		source = path
		break
	}
}

It would make sense to perhaps specify which image you would like to be imported, rather than attempting to guess which one. As an additional improvement, Amazon's VM Import supports multiple disk images so this could be implemented (it would still make sense to add an optional config to specify disk images, perhaps using an explicit list or regex/glob).

Packer version

1.5.1 (master)

Operating system and Environment details

Windows 10 Pro amd64

ghost avatar Mar 29 '21 10:03 ghost

indeed it would be great to support multiple disks in the import post-processor... Any news on this?

theblop avatar Feb 22 '23 12:02 theblop

I agree, it will be very good amazon-import post-processor to support multiple disk images.

bboychev avatar Nov 09 '23 12:11 bboychev