Interview Prep/Terraform/Secrets Provisioners and Policy as Code

How do you stop engineers from bypassing policy checks in a pipeline?

AdvancedScenarioSecrets Provisioners and Policy as Code
Answer

Situation read → A policy check that can be skipped is a suggestion.

What I'd do →

  1. Enforce policy in the system that applies (HCP Terraform policy sets with hard-mandatory enforcement), not in a script in the repo that PR authors can edit.
  2. Protect the workflow files with CODEOWNERS and branch protection; use required workflows.
  3. Remove direct apply credentials from humans.
  4. Log and review override requests (soft-mandatory).

Why → If the PR author controls the check, they control the result.

Interview tip → Know advisory, soft-mandatory and hard-mandatory.

All Terraform questions

More on Secrets Provisioners and Policy as Code