how/cicd
An engine sits between the plan and apply steps: Checkov, OPA, or Sentinel. It reads plan.json and decides whether the change can be applied. A bucket with no encryption simply will not pass.
terraform plan already told you what will change. The reviewer
from the [[tf-plan-as-artifact|PR comment]] already looked at it and
approved the change. terraform apply will run with
[[tf-oidc-aws|narrow temporary creds]]. What could go wrong?
A person can fail to notice that a new S3 bucket is created with no
encryption. Or that a security group is open to 0.0.0.0/0 on port 22.
Or that an IAM policy grants Action: "*". All of this is visible in
the plan, but a plain text plan runs 200 lines and the eye glazes over.
A policy gate solves this automatically: between plan and
apply sits an engine that reads plan.json and checks the changes
against formal rules. A violation means apply is blocked.
Press ▶ to see how this works.
A standard pipeline: terraform plan → the reviewer nods →
terraform apply. Nothing formally checks that the plan has
no compliance violations.
In a small team with disciplined engineers this works. In a large team or under deadline pressure, sooner or later an S3 bucket with public access, an RDS with no encryption, or a security group open to 0.0.0.0/0 slips through.
The gate solves this problem with automation.
recap
What to remember:
plan.json holds
all computed values, including what shows up only during the refresh.
Reading HCL with your eyes does not give you that.With this stack the whole CI/CD side is covered: the [[tf-plan-as-artifact|plan artifact]] + [[tf-oidc-aws|OIDC creds]] + a policy gate = a production-ready pipeline for Terraform.