Review S3 public ACL blocking

Block public ACL grants that are not required.

Description

Set block_public_acls = true to reject new public ACLs on the bucket or its objects. To assess current access, check existing grants, S3 Object Ownership and any stricter account-level blocks.

Potential impact

Where ACLs grant access, public read permissions can expose the object list or the contents of backups, logs and documents.

Remediation

Use aws_s3_bucket_public_access_block to reject new public ACLs. Enable ignore_public_acls to suppress existing public grants, then remove unnecessary grants. If the bucket no longer needs ACLs, move required access to policies and disable ACLs through Object Ownership.

Examples

Replace example with your bucket name. New buckets disable ACLs by default. Terraform defaults the omitted restrict_public_buckets to false. Set it explicitly if the bucket needs that protection.

Before

hcl
resource "aws_s3_bucket" "example" {
  bucket = "example"
}

resource "aws_s3_bucket_public_access_block" "example" {
  bucket = aws_s3_bucket.example.id

  block_public_acls   = false
  block_public_policy = true
  ignore_public_acls  = false
}

After

hcl
resource "aws_s3_bucket" "example" {
  bucket = "example"
}

resource "aws_s3_bucket_public_access_block" "example" {
  bucket = aws_s3_bucket.example.id

  block_public_acls   = true
  block_public_policy = true
  ignore_public_acls  = false
}

The second configuration blocks new public ACLs. Both keep ignore_public_acls = false, so check existing ACLs and bucket policy permissions.

References