Last active
May 8, 2024 14:27
-
-
Save polius/f6a0b440861ca025cfb85d22669d8309 to your computer and use it in GitHub Desktop.
Extract all AWS RDS manual snapshots from all regions into a CSV file.
This file contains hidden or 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
account="123456789" | |
echo "Account, Region, SnapshotCreateTime, DBSnapshotIdentifier, DBInstanceIdentifier, Engine, AllocatedStorage" > "$account.csv" | |
for region in $(aws ec2 describe-regions --profile customer --query "Regions[].RegionName" --output text); do | |
echo "Region: $region" | |
snapshots=$(aws rds describe-db-snapshots --profile customer --region $region --query "DBSnapshots[?SnapshotType=='manual'].[SnapshotCreateTime, DBSnapshotIdentifier, DBInstanceIdentifier, Engine, AllocatedStorage]" --output json) | |
if [ -n "$snapshots" ]; then | |
echo "$snapshots" | jq -r --arg account "$account" --arg region "$region" '.[] | "\"\($account)\",\"\($region)\"," + @csv' >> "$account.csv" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment