Immutable solution version
Terraform CI: lint and policy gates before plan
Complete solution
tflint catches provider misuse and OPA/Sentinel enforce policy, but only if they run before plan and their failures actually block the pipeline. Late or advisory gates are decoration. Not the full reference manual.
TL;DR: tflint catches provider misuse and OPA/Sentinel enforce policy, but only if they run before plan and their failures actually block the pipeline. Late or advisory gates are decoration. Lint (tflint) and policy (OPA/Conftest, Sentinel on HCP) catch those, but only if they gate the pipeline before apply. Wire lint and policy failures to fail the job, not to post a comment nobody reads.
The fix
terraform fmt -checkandterraform validate. Fast, catches formatting and static errors.tflintwith the provider rulesets you use. Catches deprecated syntax, missing required arguments, naming issues.- Policy check: Conftest/OPA against the plan JSON (
terraform show -json tfplan), or Sentinel policies on HCP Terraform runs. terraform plan -out=tfplan, review, then apply.- Gates that do not block are theater. Wire lint and policy failures to fail the job, not to post a comment nobody reads.
- Keep the policy set small and load-bearing: encryption defaults, tag requirements, no the all-interfaces address ingress. A 200-rule policy pack everyone waives is worse than five rules everyone follows.
- Run policy against the plan JSON, not the source. Source-level checks miss values computed from variables and modules.
- When a policy blocks a legitimate change, fix the policy with a reviewed PR, not with an inline exception. Exceptions accumulate into a second, shadow policy.
When to use this
- This covers exactly what the title says: Terraform CI.
- You are setting this up for the first time, or auditing an existing setup.
- You want the key gotchas in one place before you start.
When not to use this
- You are doing a different workflow with Terraform; these steps are specific to the title above.
- You need the full reference docs; this is the short path, not the manual.
Compatibility
- Not pinned to a specific version; follows current Terraform behavior.
Evidence
terraform show -json renders a plan as JSON for policy tooling; HCP Terraform supports Sentinel policy checks on runs. Verified against live docs 2026-09-26. Verified against live docs 2026-09-26.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_WJwgsQuWNmN5ZhznWyf4Mg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Terraform CI: lint and policy gates before plan <span>— Vectle</span></a>