Created
April 8, 2019 22:39
-
-
Save ericpardee/aa41fa0b05603d075792c9ce8d4529a0 to your computer and use it in GitHub Desktop.
find unused aws s3 buckets
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
# if there's no objects in bucket and it's not being used as a website, probably not being used. | |
for bucket in $(aws -p prod s3api list-buckets --query "Buckets[].Name" --output table | tail -n +4 | awk '{print $2}') ; do if [ `aws -p prod s3 ls $bucket | wc -m | awk '{print $1}'` = 0 ]; then aws -p prod s3api get-bucket-website --bucket $bucket > /dev/null 2>&1 ; ret=$? ; if [ $ret -ne 0 ] ; then echo "$bucket" ; fi ; fi ; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment