Created
May 19, 2020 19:54
-
-
Save Rovel/659306b912f720746c2b216a5a23a124 to your computer and use it in GitHub Desktop.
AWS List RDS SnapShots and check if they are public
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REGIONS=$(aws ec2 describe-regions --output json | awk -F'"' '/"RegionName":/ { print $4 }') | |
for Region in $REGIONS | |
do | |
Snaps=$(aws rds describe-db-snapshots --output json --region ${Region} | awk -F'"' '/"DBSnapshotIdentifier":/ {print $4 }') | |
if [ -z "$Snaps" ]; then | |
echo "No snapshots found in $Region" | |
echo "=======================================================" | |
else | |
echo "Snapshots in ${Region}:" | |
echo | |
echo "$Snaps" | |
echo | |
for Snapshot in $Snaps | |
do | |
echo "${Snapshot}:" | |
CheckPub=$(aws rds describe-db-snapshot-attributes --db-snapshot-identifier $Snapshot --region ${Region} --output json --query 'DBSnapshotAttributesResult' | grep -B 5 "all" | awk -F '"' '/DBSnapshotIdentifier/ {print $4}') | |
if [ -z "$CheckPub" ]; then | |
echo "Not public." | |
echo | |
else | |
echo "This snapshot \"${CheckPub}\" is public!" | |
# aws rds describe-db-snapshots --db-snapshot-identifier $CheckPub --query 'DBSnapshots[*].DBSnapshotIdentifier' | |
echo | |
fi | |
done | |
echo "=======================================================" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment