Last active
March 15, 2018 05:36
-
-
Save dennisfoconnor/e8bf3bbee1c28a54b49c to your computer and use it in GitHub Desktop.
Unused Amazon Security groups
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Originally taken from:
http://stackoverflow.com/questions/24685508/how-to-find-unused-amazon-ec2-security-groups