Last active
June 26, 2019 16:30
-
-
Save murarisumit/a5c0b625b3d6345e2dd8 to your computer and use it in GitHub Desktop.
Check for instance without termination protection #aws #boto #python #ec2
This file contains hidden or 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
import boto | |
import sys, traceback | |
import os | |
print "=== Instance without terminate protection==============" | |
conn = boto.connect_ec2(aws_access_key_id='<aws access key>',aws_secret_access_key='<aws secret key>') | |
instances = conn.get_only_instances() | |
for instance in instances: | |
attrib = instance.get_attribute("disableApiTermination") | |
if attrib["disableApiTermination"] is not True: | |
if instance.state == "running": | |
flag=False | |
print instance.tags["Name"] | |
print "=====================================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!