Interview Prep/Terraform/Secrets Provisioners and Policy as Code

Compare Sentinel, OPA/Conftest and Checkov for policy as code.

IntermediateScenarioSecrets Provisioners and Policy as Code
Answer

Situation read → You need guardrails before apply.

What I'd do →

  1. Checkov/Trivy: static scanning of HCL with hundreds of built-in rules; fast adoption.
  2. OPA with Conftest: custom Rego policies evaluated against terraform show -json plan output; vendor-neutral.
  3. Sentinel: HashiCorp's policy language, integrated into HCP Terraform with enforcement levels.
  4. Pair a built-in scanner with custom OPA or Sentinel for company-specific rules.

Why → Scanners cover generic best practice; plan-based policies can reason about final values and cost.

Interview tip → Plan-based checks catch values that only exist after expression evaluation.

All Terraform questions

More on Secrets Provisioners and Policy as Code