Interview Prep/DevSecOps/Container and IaC Security

Checkov fails a Terraform PR because an S3 bucket allows public access. What do you change?

BeginnerScenarioContainer and IaC Security
Answer

Situation read → A public bucket is one of the most common causes of data leaks.

What I'd do →

  1. Add a public access block:
resource "aws_s3_bucket_public_access_block" "this" {
  bucket                  = aws_s3_bucket.this.id
  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}
  1. Enable default encryption and versioning.
  2. If the bucket must serve public web content, use CloudFront with Origin Access Control instead.
  3. Enforce account-wide with S3 Block Public Access at account level.

Why → Block Public Access overrides any ACL or policy mistake.

Interview tip → Mention account-level block as the guardrail behind the resource-level fix.

All DevSecOps questions Roadmap: Policy as code

More on Container and IaC Security