Terraform Associate practice exam: 15 questions with answers
Below are 15 Terraform Associate (004) practice questions with answers and explanations, covering infrastructure as code, providers, the core workflow, variables, dependencies, custom conditions, sensitive data, modules and state. They are original questions from Planfile, not real exam questions or dumps. Answer each one before reading the explanation, and use the linked guides to revise any topic you miss.

About these Terraform practice questions
These 15 questions come from Planfile's own question bank. They are original questions written to practise the Terraform Associate (004) objectives. They are not real exam questions, and nothing here comes from exam dumps. The real exam is one hour of multiple-choice questions; HashiCorp doesn't publish how many, or the passing score.
Each question shows the options, then the answer, a short explanation and the exam objective it practises. Cover the answer, commit to a choice, then check. If you get one wrong, read the linked guide before moving on.
Practice questions: IaC, providers and the core workflow
1. Which statements about infrastructure as code are true? (Choose two.)
- A. Configuration can be reviewed and versioned like application code
- B. It removes the need for any cloud credentials
- C. The same configuration can create matching environments
- D. It only works with one cloud provider
Answer: A and C. IaC files live in version control, can be reviewed in pull requests, and can be applied repeatedly to build consistent environments. Credentials are still needed, and Terraform works with many providers. Objective 1b.
2. Which versions does version = "~> 1.4.0" allow?
- A. 1.4.0 and above, below 1.5.0
- B. 1.4.0 and above, below 2.0.0
- C. Exactly 1.4.0
- D. Any version from 1.4.0 up
Answer: A. With three parts, only the patch number may grow: at least 1.4.0 and below 1.5.0. Objective 2a.
3. What is .terraform.lock.hcl for?
- A. It locks state during an apply
- B. It records the exact provider versions chosen, so everyone uses the same ones
- C. It stores provider credentials
- D. It lists resources that can't be destroyed
Answer: B. The dependency lock file pins provider versions and checksums. Commit it. terraform init -upgrade updates it within your constraints. Objective 2a.
4. What does terraform validate check?
- A. That the cloud credentials work
- B. Syntax and internal consistency of the configuration
- C. That resources match the real infrastructure
- D. The formatting of the files
Answer: B. validate checks the configuration itself: syntax, argument names, types and references. It makes no API calls. Formatting is terraform fmt. Objective 3c.
Revise these topics: what is Terraform, providers and version constraints, terraform init and fmt and validate.
Practice questions: Terraform configuration
5. When should you use depends_on?
- A. Always, to be safe
- B. When a dependency exists that Terraform can't see from references
- C. Instead of references, for readability
- D. Only for data sources
Answer: B. Use depends_on only for hidden dependencies. References are clearer and Terraform already orders them. Objective 4f.
6. Which value source has the highest precedence?
- A. The variable's default
- B. terraform.tfvars
- C. TF_VAR_ environment variables
- D. -var on the command line
Answer: D. Command-line -var and -var-file options win over files, environment variables and defaults. Objective 4c.
7. What does sensitive = true on a variable do?
- A. Encrypts it in state
- B. Hides its value in CLI output
- C. Stops it being used in resources
- D. Requires it on the command line
Answer: B. It redacts the value in plan, apply and output. State still holds it in plain text. Objective 4h.
8. What does try(var.settings.port, 8080) return when settings has no port?
- A. null
- B. An error
- C. 8080
- D. An empty string
Answer: C. try returns the first argument that evaluates without an error. Objective 4e.
9. Which value can for_each take directly?
- A. A list of strings
- B. A map or a set of strings
- C. A number
- D. A tuple of objects
Answer: B. for_each takes a map or a set of strings. Convert a list with toset(). Objective 4e.
10. What can a postcondition reference that a precondition can't?
- A. var
- B. local
- C. self
- D. data
Answer: C. Postconditions run after the resource is planned and can read self, the resource's own attributes. Objective 4g.
Revise these topics: variables and outputs, for_each and count, functions and lifecycle, dependencies and conditions.
Practice questions: modules and state
11. The version argument in a module block works with which sources?
- A. Any source
- B. Registry modules only
- C. Local paths only
- D. Git repositories only
Answer: B. Only registry sources (public or private) support version. Pin Git sources with ?ref=. Objective 5d.
12. What does a remote backend with locking prevent?
- A. Two applies changing the same state at once
- B. Provider version upgrades
- C. Plans that destroy resources
- D. Reading outputs from other configurations
Answer: A. Locking stops concurrent operations from corrupting state. S3 (with lock files) and HCP Terraform both lock. Objective 6b.
13. Why can't a backend block use var.region?
- A. Backends are configured before variables are evaluated, so values must be literal or come from -backend-config
- B. Variables are sensitive
- C. Backends only accept numbers
- D. It can, if the variable has a default
Answer: A. Backend configuration is read during init, before the rest of the configuration. Use literals or terraform init -backend-config=.... Objective 6c.
14. You renamed aws_instance.web to aws_instance.app in configuration. How do you avoid a destroy and create?
- A. Nothing, Terraform detects renames
- B. Add a moved block or run terraform state mv
- C. Run terraform refresh
- D. Use -target
Answer: B. A moved { from = aws_instance.web to = aws_instance.app } block (or terraform state mv) tells Terraform it's the same object. Objective 6d.
15. Which command records changes made outside Terraform in state, without changing any infrastructure?
- A. terraform apply -refresh-only
- B. terraform plan -destroy
- C. terraform state push
- D. terraform import
Answer: A. apply -refresh-only updates state to match the real objects. It replaced the deprecated terraform refresh. Objective 6d.
Revise these topics: modules, state and backends, drift and the moved block.
How to use practice questions well
- Answer before you look. Recognising the right option is easier than producing it. Decide first, then check.
- Explain every option. For each wrong option, say why it's wrong. "
state rmforgets the object,taintis deprecated,untaintundoes taint" teaches four facts from one question. - Run it. If a question surprises you, reproduce it: write the configuration, run
terraform planorterraform console, and see what Terraform does. - Go back to the docs. The exam is written against developer.hashicorp.com. When an answer seems arguable, the docs' wording settles it.
- Space it out. Ten questions a day for three weeks beats 200 the night before. Revisit the ones you missed after a few days.
- Track objectives, not scores. If you keep missing state questions, study state; a single overall percentage hides that.
- Use HashiCorp's sample questions too. The official Terraform Associate 004 sample questions show the real question styles.
- Skip exam dumps. They are often wrong or out of date, can breach the exam agreement, and memorised answers fall apart when the wording changes.
What the Terraform Associate exam covers
The 004 exam has eight domains: infrastructure as code, Terraform fundamentals, the core workflow, configuration, modules, state management, maintaining infrastructure, and HCP Terraform. It tests Terraform 1.12, so expect current syntax: import, moved, removed and check blocks, -replace instead of taint, -refresh-only instead of refresh. Four objectives are new compared with 003: resource dependencies (4f), custom conditions (4g), sensitive data and Vault (4h), and HCP Terraform workspaces and projects (8c). The Terraform certification guide lists every objective with a study link, and the commands cheat sheet covers the CLI questions.
74 practice questions in Planfile
These 15 are a sample. Planfile has 74 original practice questions with explanations, an exam readiness score, and missed questions come back sooner so you work on your gaps. Lessons and Labs cover the topics behind them, with a simulated Terraform CLI on your iPhone. Planfile doesn't simulate HCP Terraform, so study domain 8 with HashiCorp's tutorials. It is not affiliated with HashiCorp.
Questions
Are these real Terraform Associate exam questions?
No. They are original practice questions written for Planfile to cover the 004 objectives. Real exam questions are confidential, and sites selling them as dumps are best avoided.
How many questions are on the Terraform Associate 004 exam?
HashiCorp doesn't publish a question count or passing score for 004. The exam is multiple choice and lasts one hour.
Where can I find official Terraform Associate sample questions?
HashiCorp publishes sample questions for the 004 exam in its Associate Prep (004) collection on developer.hashicorp.com, next to the learning path and exam content list.
Is there a free Terraform practice exam?
The 15 questions on this page and HashiCorp's official sample questions are free. In Planfile, chapters 1 and 2 are free, and a one-time $14.99 (US) unlocks everything, including all 74 practice questions.
How many practice questions should I do before the Terraform exam?
There's no magic number. Keep going until you can explain why every wrong option is wrong, across all eight domains, and your misses no longer cluster in one topic.