Created
July 10, 2017 01:05
-
-
Save chrisbrownie/07bfbec4718bce6ec6417c75bed720a4 to your computer and use it in GitHub Desktop.
Returns all publicly accessible S3 buckets to which the executor has access to view the ACL
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
#!/bin/bash | |
EMPTYGRANTS='{"Grants":[]}' | |
buckets=`aws s3api list-buckets --output json | jq -r '.Buckets[].Name'` | |
for bucket in $buckets; do | |
acl=`aws s3api get-bucket-acl --bucket $bucket --output json | jq -c 'del(.Owner) | .Grants |= map( select(.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers") )'` | |
if [ $acl != $EMPTYGRANTS ] ; then | |
echo "$bucket" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment