This utility updates autoscaling Launch Configurations and associated autoscaling groups with a new AMI.
This utility provides Autoscaling AMI update functionality unavailable in the AWS console or directly via the AWS CLI API.
This utility can:
- Create a new clone Launch Configuration for every Launch Configuration using the old, target AMI
- Update all clone Launch Configurations to use the new AMI
- Update all associated Autoscaling Groups to use the new Launch Configuration with the new AMI
- Retain X prior Launch Configuration versions
- Append text to the Launch Configuration name
- Enable or disable EC2 instance detailed monitoring
- Add a security group to all Launch Configurations
- Create a JSON mapping file for all related components, e.g. AMIs, Launch Configurations and Autoscaling Group(s)
This utility produces a summary report listing:
- The AWS account and alias
- The old AMI ID and name
- The new AMI ID and name
- The number of prior launch configuration versions to retain
- The number of launch configurations updated
- The number of autoscaling groups updated
- Errors
- List of prior version Launch Configurations deleted
- List of each set of new and old AMIs, new and old Launch Configurations and associated Autoscaling Groups
- Instantiate a local or EC2 Linux instance
- Install or update the AWS CLI utilities
- The AWS CLI utilities are pre-installed on AWS EC2 Linux instances
- To update on an AWS EC2 instance:
$ sudo pip install --upgrade awscli
- Create an AWS CLI named profile that includes the required IAM permissions
- See the "Prerequisites" section for the required IAM permissions
- To create an AWS CLI named profile:
$ aws configure --profile MyProfileName
- AWS CLI named profile documentation is here: Named Profiles
- Install the bash shell
- The bash shell is included in most distributions and is pre-installed on AWS EC2 Linux instances
- Install jq
- To install jq on AWS EC2:
$ sudo yum install jq -y
- To install jq on AWS EC2:
- Download this utility script or create a local copy and run it on the local or EC2 Linux instance
- Example:
$ bash ./autoscaling-update-ami.sh -p AWS_CLI_profile -n new_AMI_ID_or_name -t old_target_AMI_ID_or_name -a append-text
- Example:
- bash - Linux shell
- jq - JSON wrangler
- AWS CLI - command line utilities (pre-installed on AWS AMIs)
- AWS CLI profile with IAM permissions for the following AWS CLI commands:
- aws autoscaling create-launch-configuration
- aws autoscaling delete-launch-configuration
- aws autoscaling describe-auto-scaling-groups
- aws autoscaling describe-launch-configurations
- aws autoscaling update-auto-scaling-group
- aws ec2 describe-images (used to test AMI)
- aws iam list-account-aliases (used to pull AWS account alias)
- aws sts get-caller-identity (used to pull AWS acount)
To execute the utility:
- Example:
$ bash ./autoscaling-update-ami.sh -p AWS_CLI_profile -n new_AMI_ID_or_name -t old_target_AMI_ID_or_name -a append-text
To directly execute the utility:
- Set the execute flag:
$ chmod x autoscaling-update-ami.sh
- Execute the utility
- Example:
$ ./autoscaling-update-ami.sh -p AWS_CLI_profile -n new_AMI_ID_or_name -t old_target_AMI_ID_or_name -a append-text
- Example:
- Summary report
- JSON mapping file for all related components, e.g. AMIs, Launch Configurations and Autoscaling Group(s)
- Debug log (execute with the
-g y
parameter)- Example:
$ bash ./autoscaling-update-ami.sh -p AWS_CLI_profile -n new_AMI_ID_or_name -t old_target_AMI_ID_or_name -a append-text -g y
- Example:
- Console verbose mode (execute with the
-b y
parameter)- Example:
$ bash ./autoscaling-update-ami.sh -p AWS_CLI_profile -n new_AMI_ID_or_name -t old_target_AMI_ID_or_name -a append-text -b y
- Example:
Please read CONTRIBUTING.md for the process for submitting pull requests to us.
We use SemVer for versioning.
- Douglas Hackney - dhackney
This project is licensed under the MIT License - see the LICENSE.md file for details
- Progress bar
- Dynamic headers fprint
- Menu
- Countless other jq and bash/shell man pages, Q&A, posts, examples, tutorials, etc. from various sources