Skip to content

CICD-244 · Infrastructure policy enforcement ​

Encyclopedia · Terraform and infrastructure as code · All snippets

Previous · CICD-243 · Next · CICD-245

1. Where it fits ​

  • Placement CI plan policy job.
  • Prerequisites trusted Linux runner, Terraform CLI, reviewed IaC and a disposable state for writes.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
umask 077
terraform show -json tfplan > tfplan.json
conftest test tfplan.json --policy policy/terraform

3. How it works ​

The command renders the chosen plan into human-readable or structured evidence. Restrict access to plan output. The policy runner evaluates the supplied manifests or plan against reviewed policy code and reports violations.

4. Verify the result ​

Use a policy package with a deny rule and restricted plan evidence. A prohibited resource must produce a nonzero exit.

Validation syntax-validated (Bash parse). Status definitions.