HashiCorp Terraform Associate (004) · Section 3 · 12% of the exam
Validate a Terraform configuration
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
An engineer saved a plan with terraform plan -out=tfplan and wants to read it in a human-friendly form before approving it. Which command should be used?
- A
terraform show tfplan - B
terraform validate tfplan - C
cat tfplan - D
terraform fmt tfplan
Show the answer
A. terraform show FILE renders a saved plan; add -json for tooling. Plan files can contain sensitive values in cleartext, so keep them private.
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.