Skip to content

Instantly share code, notes, and snippets.

@combiz
Created June 22, 2022 19:47
Show Gist options
  • Save combiz/50f114d21afc785d5f02452ef67ca296 to your computer and use it in GitHub Desktop.
Save combiz/50f114d21afc785d5f02452ef67ca296 to your computer and use it in GitHub Desktop.
AWS Miscellaneous

Recursively add grantees for all objects in a folder within an S3 bucket.

In CloudShell: -

BUCKET_NAME=bucket_name
BUCKET_DIR=bucket_dir
NEW_ACL='id=12345poiuy,id=12345abcde,id=12345qwerty'

aws s3 ls --recursive $BUCKET_NAME/$BUCKET_DIR/ | \
awk '{$1=$2=$3=""; print $0}' | \
xargs -t -i \
aws s3api put-object-acl --grant-full-control $NEW_ACL --bucket $BUCKET_NAME --key {} $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment