Skip to content

Instantly share code, notes, and snippets.

@ossareh
Created October 16, 2014 20:33
Show Gist options
  • Save ossareh/18c9f58f7b1e2a5193de to your computer and use it in GitHub Desktop.
Save ossareh/18c9f58f7b1e2a5193de to your computer and use it in GitHub Desktop.
steps to clean up excessive launch configs
$ 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
#!/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