Use an AWS Config rule to detect a public bucket
Use an AWS Config rule to detect a public bucket
AWS Config records the configuration of your resources and evaluates it against rules. The managed rule s3-bucket-public-read-prohibited checks the Block Public Access settings, the bucket policy and the bucket ACL, and flags any bucket that allows public read access.
Set up AWS Config
If AWS Config is already recording in this Region, skip to Add the rule. Do not change a recorder that other people use in a shared account.
- Open the AWS Config console and choose Get started.

- In Recording strategy, choose Specific resource types, to keep the cost low.

- In Resource type, choose AWS S3 Bucket with frequency Continuous. Keep Use an existing AWS Config service-linked role.

- In Delivery channel, choose Create a bucket and enter a name such as
fcj-config-lab-<suffix>, then choose Next. Skip the rules page with Next and choose Confirm.

Add the rule
- In the AWS Config console, choose Rules → Add rule. Keep Add AWS managed rule, search for
s3-bucket-public-read-prohibited, select it and choose Next.

- Keep the default name and settings, choose Next, then Save.

Make the bucket public on purpose
- In the S3 console, open the lab bucket → Permissions → Access control list (ACL) → Edit.
- For Everyone (public access), select Objects – List, select I understand the effects of these changes on my objects and buckets and choose Save changes.

Evaluate the rule
- Back in AWS Config, open the rule s3-bucket-public-read-prohibited, choose Actions → Re-evaluate.

- After about a minute, scroll to Resources in scope and choose All. The lab bucket is Noncompliant with the annotation The S3 bucket ACL allows public read access, while the private Config delivery bucket is Compliant.

- Remove the public grant: edit the bucket ACL again, clear Everyone (public access) – List and choose Save changes.
In accounts protected by guardrails (for example AWS Organizations with automatic remediation), the public ACL may be reverted and Block Public Access turned back on within a few minutes. That is the behavior you want in production; the rule result you captured before the remediation is enough for this lab.