By using AWS re:Post, you agree to the Terms of Use

EC2 Image Builder updating Launch Templates and wiping Snapshot configuration

0

I have a pretty simple Launch Template that launches an instance with a root volume defined by the AMI, and a data volume that comes from a snapshot. Lets say this snapshot includes data that cannot be recreated within the context of the EC2 Image Builder, but also doesn't have to be mounted during the Image Builder run.

I'd like for the end result of the EC2 Image Builder to update the Launch Template to

  • Update the Root volume with the new AMI snapshot
  • Preserve the secondary volume to have the extant snapshot

If I don't specify the mounting of any secondary volume during the Image Builder run - the Snapshot specification in the Launch Template is wiped when the new Launch Template version is automatically created. If I manually update the Launch Template with the new AMI - the Snapshot specification is preserved.

From playing around with mounting the snapshot during Image Creation - I can see new snapshots being made from the Build process. However - part of the builder process involves a modification to that secondary volume - I'd like for that to not persist and for the new image to use a "clean" slate in the launch template. The changes made are not trivial to undo, so a straight up rm -rf on the secondary volume is not really an option.

Is there a way for me to preserve the original snapshot usage on the secondary volume when updating the Launch Template?

1 Answer
0

Hello,

Thank you for reaching out to us.

The Image Builder Pipeline executes a CreateLaunchTemplateVersion API call to create a new version of the Launch Template. To preserve the extant snapshot the same API needs to be executed with block device mapping specification. In AWS Web Console, creating a new version of the template automatically passes the block device mapping so the extant snapshot persists.

I have raised a feature request with the service team on your behalf to include block device mapping specification in the EC2 Image Builder Distribution settings. While I am unable to comment on if/when this feature may get released, I request you to keep an eye on our What's New and Blog pages for any new feature announcements.

Meanwhile, you may continue to manually update the Launch Template from console, or if you would like you can also update using AWS CLI by passing the block device mapping using the format:

{
    "BlockDeviceMappings":[
        {
            "DeviceName":"/dev/sdf",
            "Ebs":{
                "SnapshotId":"snap-xxxxxxxxxxxxxxxxx"
            }
        }
    ],
    "ImageId":"ami-xxxxxxxxxxxxxxxxx"
}
SUPPORT ENGINEER
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions