Terraform fundamentals Study Guide — 004

13% of the exam · domain 2 of 8 · HashiCorp Terraform Associate · Free Terraform fundamentals practice questions

0 of 41 topics covered
What the exam asks here — tap to tick off0 / 5 covered
Domain 2 of 8

Terraform Fundamentals

This domain is part of the HashiCorp Terraform Associate 004 exam (004 has been the only version since January 2026; 003 is retired). HashiCorp does not publish objective weightings, so treat it as one of the current blueprint's estimated-even-weight topic areas rather than a confirmed percentage — do not rely on a specific question count. It tests your ability to use the Terraform CLI correctly, understand the core workflow, recognize valid HCL block types and their syntax, manage variables and outputs, and work with the dependency lock file and state. Expect questions that require you to identify the correct command flag, predict what a command will do, or recognize a valid vs. invalid configuration block.


Core Terraform Workflow: init, plan, apply, destroy

The standard Terraform workflow follows a strict sequence. Understanding what each command does and when to run it is foundational.

CommandPrimary PurposeModifies State?Requires Initialized Directory?
terraform initDownload providers/modules, set up backendNoNo (creates it)
terraform planGenerate and display execution planNoYes
terraform applyExecute changes against infrastructureYesYes
terraform destroyDestroy all managed resourcesYesYes

Key facts:

  • terraform plan does not modify state or infrastructure — it is read-only.
  • terraform apply without a saved plan file runs an implicit plan first and prompts for confirmation.
  • terraform destroy is equivalent to terraform apply -destroy.
  • You must run terraform init any time you add a new provider, change a backend, or clone a configuration into a new directory.

Common traps:

  • Exam may ask if terraform plan changes state — it does not.
  • Running terraform apply on a directory that has never been initialized will fail.
  • terraform destroy does not delete your .tf files — it only removes managed infrastructure.

terraform init

terraform init prepares a working directory for use with Terraform. It is always the first command to run.

What it does:

  1. Reads the terraform and required_providers blocks to determine provider requirements.
  2. Downloads provider plugins into .terraform/providers/.
  3. Downloads module source code into .terraform/modules/.
  4. Initializes the backend (where state is stored).
  5. Creates or updates the .terraform.lock.hcl dependency lock file.

Key flags:

FlagEffect
-upgradeUpgrade providers/modules to latest allowed version
-backend=falseSkip backend initialization
-reconfigureReconfigure the backend, ignoring any existing state
-migrate-stateMigrate state from old backend to new backend
-get=falseSkip module installation

The .terraform directory is created in the working directory and should not be committed to version control. It is regenerated by terraform init.

Common traps:

  • Changing a provider version constraint and running terraform plan without re-running terraform init will cause an error — you must re-run init.
  • -reconfigure does not migrate state; -migrate-state does.
  • The .terraform directory stores provider binaries, not the state file itself (unless local backend is used separately).

Unlock with a paid plan

16 more sections (about 2,970 words) continue below. Every paid plan unlocks all 004 study guides, the full question bank and mock exams, from $4.97/month.