How to make a public S3 bucket private
Public S3 buckets are a classic data leak. Block Public Access overrides any policy or ACL that would expose objects.
Steps
- Turn on all four Block Public Access flags at the account level in the S3 console, then per bucket for exceptions.
- aws s3api put-public-access-block --bucket <name> --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
- For content that must be public, keep the bucket private and serve it through CloudFront with Origin Access Control.
How to verify
- aws s3api get-public-access-block --bucket <name> shows all four flags true.
- The bucket no longer shows a 'Public' badge in the console.
FAQ
- How do I share one file without making the bucket public?
- Use a time-limited presigned URL — it expires and the bucket stays private.
Have SkyShield check this for you
SkyShield finds this across every server and cloud account and shows the fix in plain words. Free for one server, then from $49 per server a month. Start free.