Skip to content

Instantly share code, notes, and snippets.

View rpkim's full-sized avatar

Jay Kim rpkim

View GitHub Profile
@thibautsacreste
thibautsacreste / aws.sg.unused
Last active June 4, 2024 10:12
Bash: list unused AWS security groups
#!/usr/bin/env bash
# lists all unused AWS security groups.
# a group is considered unused if it's not attached to any network interface.
# requires aws-cli and jq.
# all groups
aws ec2 describe-security-groups \
| jq --raw-output '.SecurityGroups[] | [.GroupName, .GroupId] | @tsv' \
| sort > /tmp/sg.all