Skip to content

Instantly share code, notes, and snippets.

@dennisfoconnor
Last active March 15, 2018 05:36
Show Gist options
  • Save dennisfoconnor/e8bf3bbee1c28a54b49c to your computer and use it in GitHub Desktop.
Save dennisfoconnor/e8bf3bbee1c28a54b49c to your computer and use it in GitHub Desktop.
Unused Amazon Security groups
import boto
ec2 = boto.connect_ec2()
sgs = ec2.get_all_security_groups()
total_unused = 0
for sg in sgs:
instances = len(sg.instances())
if instances < 1:
total_unused += 1
print sg.id + ',' + sg.name + ',' + sg.description
print '\n Unused security groups: ' + str(total_unused)
@dennisfoconnor
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment