CertLumen

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

  • validate checks syntax and internal consistency, needs init (-backend=false is enough) and never contacts providers or backends.
  • plan refreshes 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. -replace recreates one resource; -target is for exceptional cases.
  • plan -out saves a plan; apply FILE runs 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?

  1. Aterraform show tfplan
  2. Bterraform validate tfplan
  3. Ccat tfplan
  4. Dterraform 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.

More in this section

← Previous objective · All 37 objectives · Next objective →