Terraform Associate (004) Study Guide: Configuration, State and Real Infrastructure, and Which Command Touches Which
Most Terraform Associate questions come down to one question in disguise: which of three things does this command or block change? There is the configuration you write, the state Terraform keeps, and the real infrastructure in the cloud. Once you can say, for every command, which of the three it reads and which it writes, a large part of the exam becomes predictable. This guide is built around that idea, then covers what changed in the 004 version and how to spread your study time.
Study guide · HashiCorp Certified: Terraform Associate (004) (TF-TA004)

The exam in brief
The exam lasts one hour, is proctored online and is given in English. It tests Terraform 1.12 and includes HCP Terraform. Question types are true or false, multiple choice and multiple answer; a multiple-answer item tells you how many options to pick. HashiCorp does not publish the number of questions, the pass mark or the weight of each of the eight objectives, so check the official exam page for current details and spread your preparation evenly.
Among the 266 TF-TA004 questions in this question bank, 47 (18%) ask for more than one answer, and the largest group (40%) are use-case questions: "a team wants X, which command or block does it?" About one in five describes something going wrong. The configuration objective has the most questions in our bank because it is the broadest, with eight sub-objectives (4a-4h): variables, expressions, lifecycle rules and custom conditions all live there.
Three things, kept apart
- Configuration is what you want: the
.tffiles. - State is Terraform's last recorded view: which block is bound to which real object, plus attributes and dependencies.
- Real infrastructure is what exists right now, whoever created or changed it.
A normal plan reads all three: it refreshes its view of the real objects in state, compares the configuration with that view, and proposes actions. A block with no state entry is planned for creation. A state entry with no block is planned for destruction. An object someone built by hand and never imported is invisible to Terraform.
Which command touches which
| Command or block | What it changes |
|---|---|
init, validate, fmt | Neither state nor real infrastructure. Init installs providers and modules and sets up the backend; validate checks syntax, types and references without contacting any API; fmt rewrites file layout only. |
plan | Nothing. It is a preview. |
apply (normal) | Real infrastructure to match the configuration, then state. |
apply -refresh-only | State only, to match reality. No object is created, changed or destroyed. |
apply -replace=ADDR | One real object is rebuilt although the configuration did not change. |
import block | State, after you review it in a plan and apply. The real object is untouched. |
terraform import command | State, immediately, with no plan to review. |
moved block / state mv | The address an object is tracked under. The block is reviewed and travels with shared code; the command edits one state once. |
removed block with destroy = false / state rm | State forgets the object; the object keeps running. Without destroy = false a removed block destroys it. |
destroy | Every real object the state tracks; their entries leave state. |
force-unlock | Only the lock. Neither resources nor state contents. |
Many wrong options fail this table. "Use terraform validate to check whether the AMI exists" fails because validate never calls the provider. "Run state rm and leave the block in place" fails because the next plan creates a second copy of the object.
Going deeper: why Terraform cannot work from configuration alone
State holds three things the code cannot supply. First, the binding between an address such as aws_instance.web and a real object ID; without it, a plan against empty state proposes to create everything again, even if the objects exist. Second, dependency information: if you delete a subnet block and the instance block that used it in the same change, nothing in the code says which must go first, but state still records that the instance depends on the subnet, so destroy order is correct. Third, a cache of attributes, which lets very large configurations plan without querying every object (-refresh=false uses it, at the price of missing outside changes). That is why losing state is so expensive: every object has to be imported again.
When the three disagree: drift
Suppose someone resizes an instance in the console. The next normal plan refreshes, sees the difference and proposes to change the instance back. You now have to decide which side is right.
- The console change was a mistake: apply normally, and the configuration wins.
- The console change should stay: update the configuration to match. If you only want state to record it first, use
apply -refresh-only. On its own, that does not stop the next normal plan from reverting the change. - The object was deleted in the console: the plan proposes to create it again.
The old terraform refresh command did the refresh-only update with no review, which is why it is deprecated.
Beginner tip: you do not need a cloud account to see drift. Write one local_file resource (from the hashicorp/local provider) that creates a text file, apply it, then edit the file by hand and run terraform plan. Then try plan -refresh-only, apply -replace, a moved block after renaming the resource, and state rm followed by a plan. Ten minutes of this fills in most of the table above from memory.
What is new in 004
Four topics deserve extra attention because older study material skips them:
depends_onandcreate_before_destroyare named in the configuration objective. The first adds an ordering Terraform cannot see through references; the second builds the replacement before deleting the old object.- Custom conditions: preconditions check inputs before a resource is handled, postconditions check results after, and
checkblocks report problems as warnings without stopping the run. - Ephemeral values and write-only arguments, which keep secrets out of state and plan files.
- HCP Terraform workspaces and projects, and how an HCP workspace differs from a CLI workspace (our comparison of Terraform state and workspaces covers this in detail).
Learn the current replacements for older habits: apply -refresh-only instead of terraform refresh, apply -replace instead of taint, use_lockfile = true instead of a DynamoDB table for S3 backend locking, and the import block over the import command. The documentation marks refresh, taint and DynamoDB locking as deprecated, so when two options both work, prefer the one it currently recommends.
Going deeper: sensitive hides, ephemeral omits
Marking a variable or output sensitive = true changes only how Terraform displays the value: it is redacted in plan and apply output. The value is still written to state and to saved plan files in plain text, so anyone who can read those files can read the secret. Ephemeral variables and ephemeral resources are different in kind: they exist only during the current operation and are never written to state or plan. A write-only argument (such as password_wo on aws_db_instance) is sent to the provider during each operation and then discarded, never stored in state or plan. If a question asks how to keep a password out of state, "mark it sensitive" is the classic wrong answer.
HCP Terraform in one pass
Objective 8 is about the hosted service. Know these facts:
- A workspace holds its own state versions, variables, credentials, run history and permissions. Projects group workspaces so access can be granted in bulk.
- There are three workflows: CLI-driven (a
cloudblock plusterraform login), VCS-driven (pull requests get speculative plans that can never be applied) and API-driven. - Execution mode can be remote, agent or local. In local mode, workspace variables and policy checks are not used.
- Static provider credentials usually go in as environment variables (dynamic credentials avoid storing them); Terraform variables feed
var.inputs. Variable sets share values across workspaces. - Run triggers queue a downstream run after an upstream apply. Policy sets (Sentinel or OPA) check plans. Health assessments report drift and failing custom conditions; they never change infrastructure.
A study order
- IaC concepts and the core workflow: init, validate, plan, apply, destroy, fmt, and their main flags.
- Providers, the lock file and version constraints; then state, backends and locking.
- Configuration: variables and precedence,
countversusfor_each, expressions, lifecycle, custom conditions, secrets. - Modules, then import and the state commands, then HCP Terraform.
- Mixed practice sets against a one-hour clock.
Practise
Practise in the question bank: every question explains each option, right and wrong. Start with the domain you just studied, then take a timed mock exam.
- TF-TA004 exam page · All 326 TF-TA004 questions · Timed mock exam · 18-day study plan
- By domain: Infrastructure as Code (IaC) with Terraform · Terraform fundamentals · Core Terraform workflow · Terraform configuration · Terraform modules · Terraform state management · Maintain infrastructure with Terraform · HCP Terraform
Exam facts and objectives as described in HashiCorp's Terraform Associate (004) exam content. Question count, pass mark and objective weights are not published; check the official exam page before you book.