hashicorp / hashicorp/packer-plugin-amazon

amazon-import post-processor handles multiple disks improperly

Open
#2 2 comments 1 reaction 0 assignees View on GitHub
bug post-processor/amazon-import
Dominant language
Go
Stars
91
Forks
141
Avg merge
2d 18h
Merged PRs (30d)
3

Description

_This issue was originally opened by @benjamb as hashicorp/packer#8590. It was migrated here as a result of the [Packer plugin split](https://github.com/hashicorp/packer/issues/8610#issuecomment-770034737). 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.