packer-plugin-amazon
packer-plugin-amazon copied to clipboard
Add snapshot import to post-processor
Description
This revives the previously closed PR #104 from @Itxaka, which adds the possibility of importing an image to Amazon EC2 by using the ImportSnapshot/RegisterImage API, which has lower requirements than the ImportImage API and does not try to modify the imported image. It's motivated by the fact I can't successfully import a Fedora Cloud 42 image using the current version of the post-processor (the OS is not recognised/supported by EC2 ImportImage), but I have been able to successfully import a Fedora Cloud image built/customised using the QEMU builder with this branch of the plugin, using import_type="snapshot".
It reuses the current post-process method but diverges once we need to import the image. The artifact upload to S3 is the same, but instead of calling ImportImage, we call ImportSnapshot to create an EBS snapshot from the S3 artifact, then call RegisterImage to register the snapshot as a new AMI. The steps after registering the AMI are identical to the previous image import process. Existing uses of the post-processor without any import_type specified will continue to use ImportImage as before.
I have tried to address all the outstanding comments from Sylvia on PR #104 and rebased the changes on the latest main branch, including adding support for ARM architectures which was added to main in the years since #104 was closed. ARM architecture snapshot import requires specifying the virtualization type as hvm, which is required anyway for all recent EC2 image types, hence the addition of that parameter. All the available ARM instance types also seem to require an image with ENA support, so I have added that as a parameter too.
Resolved Issues
Closes #3 Closes #103