Domain 3 of 8 · Chapter 5 of 7

Apply changes to infrastructure

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing HashiCorp Certified: Terraform Associate premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • How apply enacts a plan
  • Skipping the prompt: -auto-approve and saved plans
  • State refresh and write-back during apply
  • Exam-pattern recognition

Three ways to apply changes

AspectPlain applyapply -auto-approveapply <saved-plan-file>
Generates a new plan first?Yes, as if you ran terraform planYes, then applies it immediatelyNo, it executes the actions already saved in the file
Prompts for approval?Yes, you type yes to proceedNo, the prompt is skippedNo, passing the file is the approval
Effect of -auto-approveSkips the promptThis is that modeIgnored; a saved plan never prompts
Refreshes state by default?Yes, unless -refresh=falseYes, unless -refresh=falseNo, it executes the actions recorded when the plan was saved
Typical useHands-on change with a reviewAutomated pipeline with no humanApply the exact plan that was reviewed

Decision tree

Applying a saved plan file?apply plan.tfplanno prompt; approval impliedYesNoReconcile state only?apply -refresh-onlyupdate state, no infra changeYesNoAutomated, no approver?apply -auto-approveskip the promptYesNoterraform applyreview plan, type yes

Cheat sheet

  • apply creates a plan and prompts for approval
  • apply makes the configured infrastructure changes
  • -auto-approve skips interactive approval
  • Applying a saved plan does not prompt
  • apply refreshes state before executing
  • apply updates state to record changes

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. Terraform core workflow overview
  2. Command: apply (Terraform CLI)
  3. Purpose of Terraform state
  4. Command: plan (Terraform CLI)