Created
April 30, 2024 15:01
-
-
Save jferris/a280b388932c5515c05094fc69c2e7ec to your computer and use it in GitHub Desktop.
List public S3 objects
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
#!/bin/sh | |
set -e | |
bucket="$1" | |
if [ -z "$1" ]; then | |
echo "Using: list-public-s3-objects BUCKET" | |
exit 1 | |
fi | |
for key in $(aws s3 ls --recursive "s3://$bucket/" | awk '{print $4}'); do | |
acl=$(aws s3api get-object-acl --bucket "$bucket" --key "$key") | |
if echo "$acl" | grep -q "AllUsers"; then | |
echo "https://$bucket.s3.amazonaws.com/$key" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment