Interview Prep/DevSecOps/Container and IaC Security

How do you enforce "no public RDS, encryption on" for all Terraform changes across teams?

IntermediateScenarioContainer and IaC Security
Answer

Situation read → Per-team review does not scale. Put the rules in code that runs against the plan.

What I'd do →

  1. Produce a plan JSON: terraform plan -out tfplan && terraform show -json tfplan > plan.json.
  2. Evaluate with OPA/conftest:
package terraform
deny[msg] {
  r := input.resource_changes[_]
  r.type == "aws_db_instance"
  r.change.after.publicly_accessible == true
  msg := sprintf("%s must not be public", [r.address])
}
  1. Run conftest test plan.json as a required check.
  2. Backstop with AWS SCPs or Config rules for anything created outside Terraform.

Why → Plan-time checks give fast feedback, SCPs give hard enforcement.

Interview tip → Say "shift-left check plus cloud-side backstop".

All DevSecOps questions Roadmap: Policy as code

More on Container and IaC Security