Configures an S3 bucket to block public access using various settings such as blocking public ACLs and policies.

Terraform Template

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

resource "aws_s3_bucket_public_access_block" "example" {
  block_public_acls = true
  block_public_policy = true
  bucket = aws_s3_bucket.example.id
  ignore_public_acls = true
  restrict_public_buckets = true
}