Last active
August 29, 2015 14:17
-
-
Save wehappyfew/a75405c3f834a12c7e55 to your computer and use it in GitHub Desktop.
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
def delete_instances(instance_tag="your_tag" , instance_state="stopped"): | |
""" | |
The function | |
1. filters all the instances by tag and instance-state | |
2. terminates/deletes the filtered instances (irreversible action!!!) | |
""" | |
reserves = conn.get_all_instances( filters={"tag-value":instance_tag , "instance-state-name":instance_state} ) | |
for r in reserves: | |
for instance in r.instances: | |
instance.terminate() | |
print "OK! instance -"+str(instance.id)+"- was deleted. \n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment