21

I'm using Elastic Load Balancing to load balance my Auto Scaling Group, for that I have a private AMI that hold my application server (Tomcat) and my web app deployed to it as war ... Now everything works fine ... what if I need to change my tomcat configuration on my AMI. Won't that require launching my AMI --> Login + Change Tomcat configuration --> Create a new AMI --> Delete Old AMI I don't think creating a new AMI is a solution since it'll require updating my Auto Scale Group to add my new AMI

Is there a way where I can update the data in my existing AMI without creating a new one? I just want to have the same AMI ID

3 Answers 3

6

You could update your configuration with a user-data script that is run when you launch your instance.

What you put in the script depends on how you manage your configuration at the filesystem level. I personnaly put my configuration files in a Mercurial repository and simply do a pull to update it.

5
  • I think your answer is valid, but in my opinion it's a hacky one ... Isn't there a way to just update my AMI image maintaining the same AMI ID?
    – Hadi Salem
    Sep 22, 2013 at 15:59
  • 3
    Unfortunately I don't think it's possible. From Amazon doc: "An AMI ID is associated with the physical bits in an image. To protect users from images being modified, we require you to reregister Amazon EC2 instance AMIs after rebundling." Sep 22, 2013 at 16:16
  • It is not possible to modify an existing AMI image. You must create a new one. Sep 22, 2013 at 20:44
  • IMO deploying config using user-data is more elegant. People are leaning in the direction of installing services at instance creation too. You may also want to look into using a CloudFormation template.
    – Edwin
    Sep 23, 2013 at 4:45
  • I think I'll be using BeanStalk with a custom AMI, it will make my life much easier, no need to set up a load balancer with autoscaling, and in case i need to change my server configuration, I'll create my own script .. Thanks all
    – Hadi Salem
    Sep 23, 2013 at 6:02
3

It is not possible to update an existing AMI and keep the same AMI id. You will either need to create a new custom AMI and update your launch configuration for the Auto Scaling group, or change your setup to apply changes to the instance after launching an instance of the base AMI as @DavidLevesque suggests.

It is a common architecture to download application, configuration, and data from, say, S3 on launch.

1
  • +1 for the note about the architecture tid-bit
    – Jmoney38
    Apr 11, 2015 at 20:04
0

This looks like an old post. But in case you're still in the same predicament, you can consider using an Instance Store-Backed Windows AMI (Bundled Task). It's also similar to an AMI but you have more control over the image itself since you practically create the image itself and store it on an S3 bucket. This will allow you to update the underlying image of your AMI every now and then when you need to without having to create a new AMI (at least that's how I understand it).

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_InstanceStoreBacked_WinAMI.html?icmpid=docs_ec2_console

1
  • FYI... "The only Windows AMIs that can be backed by instance store are those for Windows Server 2003. Instance store-backed instances don't have the available disk space required for later versions of Windows Server."
    – Rich C
    Jun 9, 2016 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .