Interview Prep/Terraform/Workflow and Providers

How would you design the plan/apply split in CI so the apply uses exactly what a reviewer approved?

IntermediateScenarioWorkflow and Providers
Answer

Situation read → Review must be tied to an immutable artifact.

What I'd do →

  1. In the PR job: terraform plan -out=tfplan, then terraform show -no-color tfplan for the PR comment and terraform show -json tfplan > plan.json for policy checks.
  2. Upload tfplan as an encrypted artifact.
  3. After approval, a gated job downloads it and runs terraform apply tfplan.

Why → The apply refuses a plan whose base state serial has changed ("Saved plan is stale"), so a drifted world fails safe instead of applying something nobody reviewed.

Interview tip → Pin the same Terraform and provider versions in both jobs, since a plan file is version-specific.

All Terraform questions Roadmap: Terraform

More on Workflow and Providers