Skip to content

Conversation

@sigmaris
Copy link

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

@sigmaris sigmaris requested a review from a team as a code owner June 19, 2025 10:22
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Jun 19, 2025

CLA assistant check
All committers have signed the CLA.

@sigmaris sigmaris force-pushed the snapshot-import branch 2 times, most recently from 127fe25 to 6bf38bc Compare June 19, 2025 13:03
This patch 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 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.

Signed-off-by: Itxaka <igarcia@suse.com>
Co-authored-by: Hugh Cole-Baker <sigmaris@gmail.com>
Signed-off-by: Hugh Cole-Baker <sigmaris@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

amazon-import -> Import as snapshot? amazon-import - improvement

1 participant