A pipeline must apply exactly the changes that were reviewed earlier in a separate job. Which approach achieves this?
- A.
Run
terraform apply -auto-approvein the second job without a plan file. - B.
Run
terraform fmtin both jobs. - C.
Run
terraform validatebefore apply. - D.
Run
terraform plan -out=tfplanin the first job andterraform apply tfplanin the second.
Show answer and explanation
Answer: D
Saving a plan file and applying it makes Terraform execute exactly that plan, so the reviewed changes are applied (or Terraform errors if state changed).
- Run
terraform apply -auto-approvein the second job without a plan file.: Terraform would create a new plan that may differ from the reviewed one. - Run
terraform fmtin both jobs.: Formatting does not preserve a plan. - Run
terraform validatebefore apply.: Validation checks syntax and not the actual change set.