Planfile

Terraform Associate practice exam: 15 questions with answers

Updated

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.

A Planfile practice question about Terraform with answer options and an explanation after answering
Practice questions in Planfile explain every answer.

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.)

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?

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?

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?

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?

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?

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?

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?

Answer: C. try returns the first argument that evaluates without an error. Objective 4e.

9. Which value can for_each take directly?

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?

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?

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?

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?

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?

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?

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

Practice questions on how Terraform works, each with an explanation, then the one-time unlock.

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.