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 →
- In the PR job:
terraform plan -out=tfplan, thenterraform show -no-color tfplanfor the PR comment andterraform show -json tfplan > plan.jsonfor policy checks. - Upload
tfplanas an encrypted artifact. - 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.
More on Workflow and Providers
A new teammate is about to run Terraform for the first time against a shared dev account. Which commands do you walk them through, and in what order?BeginnerYour manager asks why we bother with `terraform plan` when `apply` shows the same diff before asking for confirmation. What do you say?BeginnerTwo engineers get different provider versions and see different plans for the same code. How do you stop this?BeginnerSomeone committed the `.terraform/` directory to the repo. What should be in version control and what should not?BeginnerThe same configuration must create a VPC in `us-east-1` and a DR copy of a bucket in `eu-west-1`. How do you do it with one root module?IntermediateYou must deploy the same stack into 12 AWS accounts. How do you handle credentials and provider configuration?Intermediate