AWS Builder Center
How I Update Applications in an AWS Auto Scaling Group Using Golden AMIs (Without Downtime)

How I Update Applications in an AWS Auto Scaling Group Using Golden AMIs (Without Downtime)

In this article, I'm sharing the deployment process I follow to update applications running in an AWS Auto Scaling Group. This approach has helped me keep deployments consistent, reduce risk, and roll out changes with little to no downtime.

Cloud Engineer

Introduction

When I first started working with Auto Scaling Groups, one question I always had was:
"What's the safest way to deploy application updates without affecting users?"
Over time, I found that using Golden AMIs works really well. Instead of logging into every production server and making changes manually, I update one instance, create a new AMI, and let the Auto Scaling Group handle the rollout.
This keeps every instance identical and also makes rollback much easier if something goes wrong.
Here's the process I normally follow.



Step 1: Prepare an EC2 Instance

I usually start by detaching one instance from the Auto Scaling Group without reducing the desired capacity. AWS automatically launches a replacement instance, while I use the detached instance to make my changes.
If detaching isn't possible, I launch a new EC2 instance using the same AMI and configuration as production.



Step 2: Update the Application

After connecting to the instance, I deploy the latest application changes.
This could include:
  • Pulling the latest code
  • Updating configuration files
  • Restarting services
  • Installing any required packages
Once everything is updated, I make sure the application is running properly.



Step 3: Test Everything

Before creating an AMI, I spend a few minutes checking that everything is working.
I usually verify:
  • The application is running
  • APIs or websites are responding
  • Services have restarted successfully
  • Logs don't show any unexpected errors
This step is important because the AMI will be used for every new instance.



Step 4: Create a Golden AMI

Once I'm happy with the changes, I create a new AMI from that EC2 instance.
I also give it a meaningful name, something like:
myapp-prod-v2
This makes it easier to identify later if I need to roll back.



Step 5: Update the Launch Template

Next, I create a new version of the Launch Template using the new AMI.
After that, I set the new version as the default so the Auto Scaling Group knows which AMI to use.



Step 6: Start an Instance Refresh

Now comes the easiest part.
I start an Instance Refresh from the Auto Scaling Group.
AWS automatically:
  • Launches a new instance
  • Waits for health checks to pass
  • Removes one old instance
  • Repeats the process until every instance has been updated
There's no need to replace all the servers manually.



Step 7: Verify the Deployment

After the refresh is complete, I check that:
  • All Target Group instances are healthy
  • The application is working as expected
  • CloudWatch isn't showing any new alarms
  • Everything looks good from the user side
Finally, I terminate the temporary EC2 instance that I used to prepare the new AMI.



What if something goes wrong?

That's one of the biggest advantages of this approach.
If I find any issue after deployment, I simply change the Launch Template back to the previous version and start another Instance Refresh.
AWS gradually rolls back the environment to the previous AMI.



Final Thoughts

This is the deployment process I follow for applications running in Auto Scaling Groups. It has helped me keep deployments consistent, reduce manual work, and make rollbacks much less stressful.
There are many ways to deploy applications on AWS, but this approach has worked well for me in day-to-day operations.
I'd be interested to know how you handle deployments in your environment. Do you use Golden AMIs, CodeDeploy, or a different strategy?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article