TF-004 Implement and maintain state Practice Question
Exhibit
Error: Error loading state:
Terraform state file does not exist.Refer to the exhibit. A user runs `terraform plan` and receives this error. The user is using a local backend. Which of the following is the most likely cause?
⚠ Common exam trap
A common trap in Terraform exams is confusing a missing directory for the local state file with state file corruption or an incorrect workspace selection. The error typically indicates that the parent directory path does not exist, not that the file itself is unreadable.
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 configured state file path's directory does not exist.
With a local backend, Terraform stores state in a local file, typically `terraform.tfstate`. The error indicates that the directory specified for the state file path does not exist. Terraform requires the parent directory to exist before it can write the state file; if it is missing, the plan fails with this error.
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 workspace is not selected correctly.
Why it's wrong here
"The workspace is not selected correctly." This is incorrect because issues with workspace selection typically manifest as errors indicating a specific workspace does not exist within the configured backend, or Terraform defaulting to the `default` workspace if none is specified. Such errors relate to the logical organization of state within an existing backend, not a fundamental file system error where the parent directory for the state file itself is missing. Terraform would still attempt to access or create a state file within a valid, existing directory structure.
- ✓
The configured state file path's directory does not exist.
Why this is correct
"The configured state file path's directory does not exist." This is the correct explanation. Terraform requires the parent directory for its state file (e.g., `terraform.tfstate` by default, or a custom path specified in a `local` backend block) to exist on the file system *before* it can write or update the state file. If the directory specified in the backend configuration, or the default `.terraform` directory where state files are typically stored, is missing, Terraform cannot proceed, resulting in an error indicating the directory does not exist.
- ✗
The state file is corrupted.
Why it's wrong here
"The state file is corrupted." This is incorrect because a corrupted state file would typically lead to parsing errors when Terraform attempts to read its contents, indicating an invalid JSON or HCL structure. The error message "configured state file path's directory does not exist" specifically points to a missing file system location, not an issue with the integrity or format of an existing state file. Terraform cannot even attempt to parse a file if its containing directory is absent.
- ✗
The backend is misconfigured for remote state.
Why it's wrong here
"The backend is misconfigured for remote state." This is incorrect because the error "configured state file path's directory does not exist" explicitly refers to a local file system path. If a remote backend (e.g., S3, Azure Blob Storage, Terraform Cloud) were configured, error messages would typically relate to network connectivity, authentication failures, or issues with the remote storage bucket/container's existence or permissions, not a local directory path. This specific error indicates a problem with the local state file's storage location.
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 →
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.