Re-bundle (or update) an EC2 AMI?

7,226

Solution 1

What I do is bundle the AMI with the same name. Then delete the AMI while the instance is running and the upload and register the new AMI. In terms of what's "better" for storing your software it really depends on how often you're going to updating or modifying it. If you don't mind going thru the bundle process then just leave it in the AMI.

p.s. Handy tip for bundling AMI's is do it inside a screen session so that you can walk away from the imaging process and not have to worry about a broken SSH connection.

Solution 2

Although it probably doesn't help you now. It is much easier to bundle EBS backed instances. It is as simple as "stopping" the instance somehow (Via ec2-stop-instances, or xfs freeze, or just try your luck with a running one) then just snapshot the EBS volume and register it. The only tricky part is when launching the new instance to make sure you use the same AKI, which can be found in the info for the currently running instance. Also, the AMIs from EBS Backed Images are not stored in your standard S3 bucket, so you do not need to worry so much about proliferation, just deregister them when you are done.

Alternatively, you can try writing the regular AMI bundle to an attached drive, then snapshot and register that, although I haven't had much success with this yet. Moving instance-store to EBS backed isn't entirely smooth at the moment.


Amazon tracks AMI's by the AMI ID (ami-1a2s3d4f) not by the location and name in S3, so you will be fine to remove the old one and bundle the other one with the same name.

Share:
7,226

Related videos on Youtube

Max A.
Author by

Max A.

Updated on September 17, 2022

Comments

  • Max A.
    Max A. almost 2 years

    I have bundled an AMI that I'm fairly satisfied with. However I know that eventually I'll need to modify it (e.g. for Debian security updates or to update other system software that I have in the AMI). Is it possible to update an image once it's been bundled? What if I bundled a new AMI with the same name, manifest, and S3 location? EC2 caches AMIs for a period of time; would it be thrown off guard by the fact that an AMI changed between launches?

    I do understand that I can simply bundle an entirely new AMI, although I want to avoid a proliferation of images. Would I be better off storing at least some of my software (e.g. JRuby and such) on an EBS volume instead of the AMI itself?

    Note that the "software" I'm referring to does not include my own deployable units, but is rather third-party software.

  • Mark Rose
    Mark Rose over 12 years
    I'd avoid doing that -- if there's a problem with your new AMI, there's no easy way to launch copies of the old one while you fix things.