code-dumps/aws/find-unused-sg.sh

7 lines
254 B
Bash
Raw Normal View History

2022-11-03 14:59:51 +08:00
#!/bin/bash
aws ec2 describe-security-groups | jq -cr '.SecurityGroups[].GroupId' | while read s; do
echo -n "$s: "
aws ec2 describe-network-interfaces --filters Name=group-id,Values=$s | jq -cr '[.NetworkInterfaces[].NetworkInterfaceId] | length'
done