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

7 lines
254 B
Bash
Executable File

#!/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