TF-004 Understand Terraform's purpose Practice Question
A new user is learning Terraform. They write a configuration file and run terraform apply expecting to provision resources. However, they forgot to run terraform init first. What will happen?
⚠ Common exam trap
Test-takers frequently assume Terraform is self-sufficient and will auto-initialize, or confuse `validate` with `init`, not realizing that provider plugins and backend state are prerequisites for any execution.
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
✓
Terraform will return an error stating that the working directory is not initialized.
Terraform requires the working directory to be initialized with `terraform init` before any plan or apply can be executed. The `init` command downloads the necessary provider plugins and sets up the backend state storage. Without it, Terraform has no knowledge of the providers or state configuration, so it returns an error stating that the working directory is not initialized.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Terraform will successfully apply the configuration because validate is enough.
Why it's wrong here
"terraform validate" primarily checks the syntax and internal consistency of the configuration files, ensuring that the code adheres to HCL (HashiCorp Configuration Language) rules and references valid resources or variables. However, it does not download necessary providers, install modules, or configure the backend state. A "terraform apply" operation critically depends on these components being present and correctly set up, which "validate" alone cannot achieve. Therefore, "validate" is insufficient for a successful "apply" in an uninitialized directory.
- ✗
Terraform will automatically run init before applying.
Why it's wrong here
Terraform commands operate explicitly, meaning each command must be invoked by the user. While "terraform apply" inherently relies on the artifacts generated by "terraform init," such as downloaded provider plugins and backend configuration, Terraform does not possess an automatic pre-execution mechanism to run "init" if it detects an uninitialized state. The user must always manually execute "terraform init" to prepare the working directory before attempting any "plan" or "apply" operations.
- ✗
Terraform will prompt to run init and then continue.
Why it's wrong here
Terraform's command-line interface is designed for non-interactive execution, making it suitable for scripting and automation pipelines. When "terraform apply" is attempted in an uninitialized directory, Terraform will not present an interactive prompt asking the user to run "init" or offer to do so automatically. Instead, it will immediately terminate the operation with a clear error message, requiring the user to explicitly run "terraform init" before any further actions can be taken.
- ✓
Terraform will return an error stating that the working directory is not initialized.
Why this is correct
When "terraform apply" is executed in a working directory that has not been initialized, Terraform cannot proceed with the requested operation. The "apply" command fundamentally depends on the presence of downloaded provider plugins, a configured state backend, and potentially installed modules, all of which are established during the "terraform init" phase. Consequently, Terraform will halt execution and output a specific error message, clearly indicating that the working directory requires initialization before the "apply" command can be successfully executed.
Go deeper
Related to this question
About these practice questions
One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
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.