Skip to content

Instantly share code, notes, and snippets.

@pataiji
Last active September 22, 2021 04:42
Show Gist options
  • Save pataiji/ddd2d3f5c351c1a81abcd10443f1e520 to your computer and use it in GitHub Desktop.
Save pataiji/ddd2d3f5c351c1a81abcd10443f1e520 to your computer and use it in GitHub Desktop.
Restrict public access to all S3 buckets.
#!/bin/bash
aws s3api list-buckets | \
jq '.Buckets[].Name' -r | \
AWS_PAGER="" xargs -IXXX aws s3api put-public-access-block \
--bucket XXX \
--public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment