How do you prevent public S3 buckets from ever reaching production via Terraform?
IntermediateScenarioSecrets Provisioners and Policy as Code
Answer
Situation read → Defence in depth.
What I'd do →
- Module default:
aws_s3_bucket_public_access_blockwith all four flagstrue. - CI scan:
checkov -d . --framework terraformfails the PR on public ACLs. - Account-level S3 Block Public Access and an SCP as backstop.
Why → If a resource slips through code review, the account control still blocks it.
Interview tip → Layer the checks: module, pipeline, org.
More on Secrets Provisioners and Policy as Code
A developer hardcodes a DB password in `terraform.tfvars` and commits it. What do you do right now, and what's the long-term fix?BeginnerHow do you avoid Terraform persisting a secret in state when creating a secret in AWS Secrets Manager?AdvancedSomeone wants a `remote-exec` provisioner to configure servers after creation. What's your advice?BeginnerYou must run a one-off command after a resource is created, such as registering with an external system.IntermediateHow do you generate and manage the master password for a new RDS instance?IntermediateCompare Sentinel, OPA/Conftest and Checkov for policy as code.Intermediate