HashiCorp Terraform Associate (004) · Section 3 · 12% of the exam
Apply changes to infrastructure with Terraform
One of the objectives of the HashiCorp Certified: Terraform Associate (004) exam, in the section “Core Terraform workflow”. Here is what it covers, the points to remember and a question to try.
What it covers
Validate catches configuration mistakes without contacting any provider. Plan refreshes state and shows exactly what would change, and apply carries the plan out. This lesson covers how to read plan output, the planning modes and options, saved plans, and what happens when an apply fails.
Points to remember
validatechecks syntax and internal consistency, needs init (-backend=falseis enough) and never contacts providers or backends.planrefreshes state, compares it with the configuration and proposes changes without applying them.- Plan symbols:
+create,-destroy,~update in place,-/+replace (destroy then create),+/-replace (create then destroy),<=read. - Planning modes: normal,
-destroy,-refresh-only.-replacerecreates one resource;-targetis for exceptional cases. plan -outsaves a plan;apply FILEruns it without a prompt and rejects it if state changed (stale plan).
Try a question
A reviewer asks what terraform plan does to the real infrastructure when it runs. Which answer is correct?
- ANothing is created, changed or destroyed; it only previews what apply would do
- BIt creates new resources that are missing but does not delete or modify existing ones
- CIt applies the changes after asking for approval and then updates the state
- DIt formats the files, validates them and then updates the state
Show the answer
A. Plan refreshes state, compares the configuration with it and proposes operations. Only apply carries them out.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Validate, plan and apply teaches this objective (about 45 minutes), and 21 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.