Skip to content

Instantly share code, notes, and snippets.

@mgeeky
Created May 28, 2019 15:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgeeky/dd653ef3ec3aa8805264fb6a31244a54 to your computer and use it in GitHub Desktop.
Save mgeeky/dd653ef3ec3aa8805264fb6a31244a54 to your computer and use it in GitHub Desktop.
One-liner that dumps all of the S3 buckets from different regions and all their Bucket policies.
P=aws-profile; for region in `aws ec2 describe-regions --output text | cut -f3`; do for bucket in `aws --region $region --profile $P s3api list-buckets --query 'Buckets[*].Name' --output text | tr '\t' '\n'`; do aws --profile $P --region $region s3api get-bucket-policy --bucket $bucket --query 'Policy' --output text 2> /dev/null | jq '.' | tee $P-$bucket.json ; done ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment