Skip to content

Instantly share code, notes, and snippets.

@Voronenko
Created September 26, 2022 10:42
Show Gist options
  • Save Voronenko/f77bdd5d19c28990816777d1712d6e3d to your computer and use it in GitHub Desktop.
Save Voronenko/f77bdd5d19c28990816777d1712d6e3d to your computer and use it in GitHub Desktop.
DOES NOT take into consid. LB
#!/usr/bin/bash
# all groups
aws ec2 describe-security-groups \
| jq --raw-output '.SecurityGroups[] | [.GroupName, .GroupId] | @tsv' \
| sort > /tmp/sg.all
# groups in use
aws ec2 describe-network-interfaces \
| jq --raw-output '.NetworkInterfaces[].Groups[] | [.GroupName, .GroupId] | @tsv' \
| sort \
| uniq > /tmp/sg.in.use
diff /tmp/sg.all /tmp/sg.in.use |grep "<" |cut -d ' ' -f2-3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment