**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

1. `terraform fmt -check` and `terraform validate`. Fast, catches formatting and static errors.

2. `tflint` with the provider rulesets you use. Catches deprecated syntax, missing required arguments, naming issues.

3. Policy check: Conftest/OPA against the plan JSON (`terraform show -json tfplan`), or Sentinel policies on HCP Terraform runs.

4. `terraform plan -out=tfplan`, review, then apply.

5. Gates that do not block are theater. Wire lint and policy failures to fail the job, not to post a comment nobody reads.

6. 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.

7. Run policy against the plan JSON, not the source. Source-level checks miss values computed from variables and modules.

8. 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.