Created
October 5, 2020 09:34
-
-
Save ThabetAmer/e5a65a1b44d96863b9854eaa6bb8de21 to your computer and use it in GitHub Desktop.
AWS S3 bash script to make recent objects uploaded by other owners publicly accessible
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/bash | |
BUCKET= | |
PROFILE_OTHER= | |
PROFILE_MINE= | |
DATE=$(date +%Y-%m-%dT%H:00:00) | |
IFS=$'\t' | |
for KEY in $(aws --profile $PROFILE_MINE s3api list-objects --bucket $BUCKET --query 'Contents[?LastModified>="'$DATE'"][].Key' --output text) | |
do | |
echo $KEY | |
# grant access to the account holder | |
aws --profile $PROFILE_OTHER s3api put-object-acl --bucket $BUCKET --key "$KEY" --acl bucket-owner-full-control | |
# make the object public | |
aws --profile $PROFILE_MINE s3api put-object-acl --bucket $BUCKET --key "$KEY" --acl public-read | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment