Skip to content

Instantly share code, notes, and snippets.

@polius
Last active May 8, 2024 14:27
Show Gist options
  • Save polius/f6a0b440861ca025cfb85d22669d8309 to your computer and use it in GitHub Desktop.
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.
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