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.
| Command | Primary Purpose | Modifies State? | Requires Initialized Directory? |
|---|---|---|---|
terraform init | Download providers/modules, set up backend | No | No (creates it) |
terraform plan | Generate and display execution plan | No | Yes |
terraform apply | Execute changes against infrastructure | Yes | Yes |
terraform destroy | Destroy all managed resources | Yes | Yes |
Key facts:
terraform plandoes not modify state or infrastructure — it is read-only.terraform applywithout a saved plan file runs an implicit plan first and prompts for confirmation.terraform destroyis equivalent toterraform apply -destroy.- You must run
terraform initany time you add a new provider, change a backend, or clone a configuration into a new directory.
Common traps:
- Exam may ask if
terraform planchanges state — it does not. - Running
terraform applyon a directory that has never been initialized will fail. terraform destroydoes not delete your.tffiles — 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:
- Reads the
terraformandrequired_providersblocks to determine provider requirements. - Downloads provider plugins into
.terraform/providers/. - Downloads module source code into
.terraform/modules/. - Initializes the backend (where state is stored).
- Creates or updates the
.terraform.lock.hcldependency lock file.
Key flags:
| Flag | Effect |
|---|---|
-upgrade | Upgrade providers/modules to latest allowed version |
-backend=false | Skip backend initialization |
-reconfigure | Reconfigure the backend, ignoring any existing state |
-migrate-state | Migrate state from old backend to new backend |
-get=false | Skip 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 planwithout re-runningterraform initwill cause an error — you must re-runinit. -reconfiguredoes not migrate state;-migrate-statedoes.- The
.terraformdirectory 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.