Study HashiCorp Terraform 004 Init and Validate: key concepts, common traps, and exam decision cues.
These commands often look simple, but they solve different problems. The exam rewards candidates who know exactly which step prepares dependencies, which one normalizes style, and which one checks configuration structure.
| Command | Main job |
|---|---|
terraform init |
prepare the working directory, backend, providers, and modules |
terraform fmt |
normalize style and formatting |
terraform validate |
check configuration structure and validity |
| Trap | Better rule |
|---|---|
saying init creates infrastructure |
initialization prepares the directory; it does not apply changes |
saying fmt validates behavior |
formatting is style, not semantic correctness |
saying validate replaces planning |
validation checks configuration, not proposed infrastructure change |
init to setupfmt to style hygienevalidate to config correctnessWorkflow questions are mostly about picking the right step for the current moment. If the directory is not prepared, start with init. If the configuration needs consistent style, use fmt. If you need a syntax-and-structure check before planning, use validate. The wrong answer is usually the command from a later phase of the lifecycle.