Skip to content

Instantly share code, notes, and snippets.

@jferris
Created April 30, 2024 15:01
Show Gist options
  • Save jferris/a280b388932c5515c05094fc69c2e7ec to your computer and use it in GitHub Desktop.
Save jferris/a280b388932c5515c05094fc69c2e7ec to your computer and use it in GitHub Desktop.
List public S3 objects
#!/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