Skip to content

Instantly share code, notes, and snippets.

@nfelsen
Created September 9, 2015 05:44
Show Gist options
  • Save nfelsen/dc1e89435948ead2ecbf to your computer and use it in GitHub Desktop.
Save nfelsen/dc1e89435948ead2ecbf to your computer and use it in GitHub Desktop.
unused aws vpc security group assuming all securitry groups are used by either RDS or EC2
comm -23 <(aws --region us-east-1 ec2 describe-security-groups --query 'SecurityGroups[*].GroupId' --output text | tr '\t' '\n'| sort) <(((aws --region us-east-1 ec2 describe-instances --query 'Reservations[*].Instances[*].SecurityGroups[*].GroupId' --output text | tr '\t' '\n') ; (aws --region us-east-1 rds describe-db-instances --query 'DBInstances[*].VpcSecurityGroups[*].VpcSecurityGroupId' --output text | tr '\t' '\n')) | sort | uniq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment