Skip to content

Instantly share code, notes, and snippets.

@wliao008
Last active June 21, 2017 14:49
Show Gist options
  • Save wliao008/5a36a45caf8c7741a587413632816c81 to your computer and use it in GitHub Desktop.
Save wliao008/5a36a45caf8c7741a587413632816c81 to your computer and use it in GitHub Desktop.
Quick (kinda) way to find unused aws launch configurations
1. Get the list of all launch configurations
aws autoscaling describe-launch-configurations
--region us-east-1
--output text
--query 'LaunchConfigurations[*].LaunchConfigurationName' > launch_configs.txt
2. Get the list of in-use launch configurations from auto scaling groups, these are the configurations that are in use.
aws autoscaling describe-auto-scaling-groups
--region us-east-1
--output text
--query 'AutoScalingGroups[*].LaunchConfigurationName' > asg_launch_configs.txt
3. Turn tabs char into newline so they can be sorted
cat launch_configs.txt | tr "\t" "\n" | sort > launch_configs_sorted.txt
cat asg_launch_configs.txt | tr "\t" "\n" | sort > asg_launch_configs_sorted.txt
4. Diff the 2 files, in a tool such as https://www.diffchecker.com/diff, now you should see list of configurations highlighted that are not in use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment