Most Terraform pipelines run terraform plan on the pull request, a human reads it, and then a different job runs terraform apply -auto-approve after the merge. Those are two separate plans. Anything that changed in between, such as another merge, a manual console edit or a provider update, gets applied without anyone having read it.
The fix is small: apply the plan file the reviewer actually saw.
The two commands
terraform plan -input=false -lock-timeout=60s -out=tfplan terraform apply -input=false tfplan
Enter fullscreen mode
Exit fullscreen mode
terraform apply tfplan does not plan again. It applies exactly what is in the file. If the state has changed since the plan was made, Terraform refuses with a "saved plan is stale" error instead of applying something nobody reviewed. That refusal is the feature.
Showing the plan to a human
A plan file is binary.…