Auto update ASG with latest image and launch config

Normally, we create AMIs manually and update the launch configurations of different auto scaling groups using those AMIs. This kind of repetitive work becomes tedious on a daily basis and there’s no such feature in AWS to do this automatically.

After getting frustrated, I thought of getting this fixed on a permanent basis. Using my knowledge of shell scripting and basic AWS CLI commands, I have created a shell script to do this automatically.


What does this script do ?

Well, the script is straight-forward. Pass the autoscaling group name parameter to it and it will randomly pick any 1 instance from it and then create it’s AMI. Once the AMI is created, the script will then fetch the existing launch configuration, create a new one with existing parameters, except the AMI of course, and attach it to the autoscaling group.

How to choose a specific instance from ASG ?

In that case, you can specify the instance ID as well along with the autoscaling group name. The script will then create it’s AMI and update the launch configuration. Easy Peasy !!

Where is the script ?

The script can be found in the link here: https://github.com/varunchandak/automate-launch-configuration-update-with-latest-image. Make sure to go through the README carefully and test it in your development environment before executing it in the production environment.


Any bugs or enhancements are welcome. Enjoy !

amazon web services aws awscli cloud ec2 asg