Skip to content

Instantly share code, notes, and snippets.

@JcBanks
Created August 21, 2017 13:01
Show Gist options
  • Save JcBanks/c8e6bb07f649a70518c27055fa0adbad to your computer and use it in GitHub Desktop.
Save JcBanks/c8e6bb07f649a70518c27055fa0adbad to your computer and use it in GitHub Desktop.
Bulk S3 bucket logging update
Objective update all s3 buckets to a single logging bucket
Variables:
Target Bucket: [AccountId].logs
Target Prefix: s3/
Replace $TargetPrfix and $TargetBucket
for i in `aws s3api list-buckets --query "Buckets[].Name" --output text`;do aws s3api put-bucket-logging --bucket $i --bucket-logging-status '{"LoggingEnabled":{"TargetPrefix":"$TargetPrfix'$i'/","TargetBucket":"'$TargetBucket'"}}';done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment