EC2 Update my existing AMI
Solution 1
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.
Solution 2
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.
Related videos on Youtube
Hadi Salem
Updated on September 18, 2022Comments
-
Hadi Salem over 1 year
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
-
Hadi Salem over 10 yearsI 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?
-
David Levesque over 10 yearsUnfortunately 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."
-
Matt Houser over 10 yearsIt is not possible to modify an existing AMI image. You must create a new one.
-
Edwin over 10 yearsIMO 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.
-
Hadi Salem over 10 yearsI 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
-
Jmoney38 about 9 years+1 for the note about the architecture tid-bit
-
Rich C almost 8 yearsFYI... "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."