Created
October 16, 2014 20:33
-
-
Save ossareh/18c9f58f7b1e2a5193de to your computer and use it in GitHub Desktop.
steps to clean up excessive launch configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install awscli | |
$ aws configure | |
$ aws autoscaling describe-launch-configurations | grep LaunchConfigurationName | cut -d '"' -f4 > all_lcs | |
$ aws autoscaling describe-auto-scaling-groups | grep LaunchConfigurationName | cut -d '"' -f4 | sort -u > used_lcs | |
$ ./delete.py > delete_lcs | |
$ for i in `cat delete_lcs`; do aws autoscaling delete-launch-configuration --launch-configuration-name ${i}; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
in_use=[] | |
with open("./used_lcs") as fd: | |
for lc in fd.readlines(): | |
in_use.append(lc.strip()) | |
to_remove=[] | |
with open("./all_lcs") as fd: | |
for lc in fd.readlines(): | |
lc = lc.strip() | |
if lc not in in_use: | |
to_remove.append(lc) | |
for lc in to_remove: | |
print lc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment