NEW: script to list unused SG

This commit is contained in:
xpk 2023-06-07 13:39:37 +08:00
parent 83ed100299
commit 1ddc2f2fe0
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86

9
aws/list-unused-sg.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
aws ec2 describe-network-interfaces --query NetworkInterfaces[].Groups --output text > /tmp/enisg.lst
for sg in $(aws ec2 describe-security-groups --query 'SecurityGroups[*].GroupId' --output text); do
echo -n "$sg : "
grep -c $sg /tmp/enisg.lst
done | sort -k3 -n
rm -f /tmp/enisg.lst