Drag steps to the numbered slots on the right, or tap a step then tap a slot.
TF-004 Understand IaC concepts Practice Question
Drag and drop the steps to initialize a Terraform working directory in the correct order.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
Write Terraform configuration files, then run terraform init, then run terraform validate.
Initialization begins after writing configs; terraform init downloads providers/modules, creates .terraform directory, and validate checks syntax.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Write Terraform configuration files, then run terraform init, then run terraform validate.
Why this is correct
This is the correct order because you must first have configuration files to define providers and modules; terraform init then downloads them and initializes the working directory; terraform validate checks syntax and validity after initialization is complete.
- ✗
Run terraform init, then write Terraform configuration files, then run terraform validate.
Why it's wrong here
`terraform init` is designed to scan existing configuration files to identify and download necessary provider plugins and modules, as well as initialize the backend. Running `init` when no `.tf` files are present means it cannot determine what components to fetch or how to configure the working directory. This will lead to an error indicating no configuration files were found, or an incomplete initialization that lacks essential dependencies.
- ✗
Write Terraform configuration files, then run terraform validate, then run terraform init.
Why it's wrong here
While configuration files are present, `terraform validate` performs comprehensive checks that extend beyond basic syntax, including verifying provider configurations and module sources. These deeper validations require the provider plugins and module dependencies to be downloaded and the backend initialized by `terraform init`. Running `validate` prematurely will result in errors about missing providers or uninitialized modules because the `.terraform` directory, containing these critical components, has not yet been established.
- ✗
Run terraform validate, then write Terraform configuration files, then run terraform init.
Why it's wrong here
Attempting to run `terraform validate` before any configuration files are written means there is no code for Terraform to check, resulting in an immediate error. Even if empty files existed, `validate` also performs checks that require provider plugins to be downloaded and the backend initialized by `terraform init`. Therefore, this sequence fails because the necessary configuration and environment setup are entirely absent.
Go deeper
Related to this question
About these practice questions
Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.