TF-004 Use Terraform outside the core workflow Practice Question
Exhibit
Refer to the exhibit.
```
# backend.tf
terraform {
backend "remote" {
organization = "myorg"
workspaces {
name = "example-workspace"
}
}
}
# main.tf
resource "null_resource" "example" {
triggers = {
always = timestamp()
}
provisioner "local-exec" {
command = "echo '${self.id}'"
}
}
```
When running `terraform plan` locally, the user receives the error: "Error: Backend initialization required: please run 'terraform init'".The user runs `terraform init` successfully, but then `terraform plan` still fails with a different error: "Error: No configuration files found in this directory." The directory contains backend.tf and main.tf. What is the most likely cause?
⚠ Common exam trap
HashiCorp often tests the distinction between configuration errors (like syntax or backend issues) and operational errors (like working directory), leading candidates to overthink complex backend or syntax problems when the real issue is a simple path mismatch.
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
✓
The user is not in the same directory as the .tf files.
The error 'No configuration files found in this directory' indicates that Terraform cannot locate any .tf files in the current working directory. Even though the directory contains backend.tf and main.tf, the user must be in that directory when running `terraform plan`. This is a common path issue, not a configuration or syntax problem.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The backend block is misconfigured.
Why it's wrong here
terraform init is the command responsible for configuring and initializing the backend. If the backend block were misconfigured, terraform init would have failed, typically with an error message indicating issues with backend parameters or connectivity. Since init succeeded, the backend configuration was valid and successfully established, making this option incorrect.
- ✓
The user is not in the same directory as the .tf files.
Why this is correct
Terraform commands, including plan and apply, by default search for .tf configuration files exclusively within the current working directory. If the user executes these commands from a different directory where the .tf files are not present, Terraform will report that no configuration files were found, even if terraform init previously succeeded in the correct location.
- ✗
The workspace name in the backend configuration is incorrect.
Why it's wrong here
An incorrect workspace name within the backend configuration would typically manifest as an error during terraform workspace select or terraform init if the backend specifically validates workspace existence during initialization. However, an invalid workspace name does not prevent Terraform from discovering .tf configuration files in the current directory, nor does it cause a 'no configuration files' error, which relates to local file system discovery.
- ✗
The main.tf file contains invalid syntax.
Why it's wrong here
If main.tf or any other .tf file contained invalid HCL syntax, Terraform would typically generate a specific parsing error, often detailing the file path and line number where the syntax issue was detected. The error 'no configuration files' indicates that Terraform did not locate any .tf files to parse at all, rather than failing to parse existing ones due to syntax errors.
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.