Shafique Jamal
Shafique Jamal

Reputation: 1688

How do I use the aws cli to block public access to all of my buckets?

I would like the the "Access" column in the web console bucket list to read "not public" for each bucket.

Upvotes: 1

Views: 254

Answers (1)

Shafique Jamal
Shafique Jamal

Reputation: 1688

for BUCKET_NAME in $(aws s3 --profile YOUR_PROFILE_HERE ls s3:// | cut -d' ' -f3); do aws s3api --profile YOUR_PROFILE_HERE put-public-access-block --bucket "$BUCKET_NAME" --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"; done;

Upvotes: 1

Related Questions