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개 답변
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"
}
AWS
지원 엔지니어
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠