Terraform State Storage: Local vs Remote Backend Recovery
A developer accidentally deletes the local terraform.tfstate file. The backend is configured to store state remotely in an S3 bucket. What is the effect on Terraform operations?
Quick Answer
The answer is that Terraform will automatically recover the state from the remote backend on the next plan or apply. This is correct because when a remote backend like S3 is configured, Terraform treats the remote state as the single source of truth; the local terraform.tfstate file is merely a cached copy that can be safely deleted. The core technical concept here is that remote backends enable state recovery by design—Terraform fetches the authoritative state from the remote location during initialization and every subsequent operation, so losing the local file has no impact on your infrastructure management. On the HashiCorp Terraform Associate TF-003 exam, this question tests your understanding of how remote state backends decouple state storage from the local filesystem, a common trap being the assumption that the local file is essential. A useful memory tip: think of the local state file as a temporary scratchpad—if you lose it, the remote backend is the permanent notebook that never goes missing.
⚠ Common exam trap
The HashiCorp exam often tests the misconception that Terraform requires a local state file to operate, but with a remote backend, the local file is merely a cache and its deletion does not disrupt operations.
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 automatically recover the state from the remote backend on the next plan or apply.
When a remote backend (e.g., S3) is configured, Terraform stores the state file in the remote location and maintains a local copy as a cache. Deleting the local terraform.tfstate file does not affect the remote state. On the next plan or apply, Terraform automatically pulls the latest state from the remote backend, effectively recovering it without data loss or manual intervention.
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 create a new empty state file, losing all existing managed resources.
Why it's wrong here
Incorrect. Terraform will not create a new empty state; it uses the remote state.
- ✗
Terraform will fail with an error because the local state is missing.
Why it's wrong here
Incorrect. Terraform does not require a local state file when a remote backend is configured; it reads from the backend.
- ✓
Terraform will automatically recover the state from the remote backend on the next plan or apply.
Why this is correct
Correct. With a remote backend, Terraform downloads the state from the remote source; the local file is not the authoritative copy.
- ✗
Terraform will prompt the user to confirm whether to use the remote state.
Why it's wrong here
Incorrect. There is no prompt; Terraform uses the remote backend automatically.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
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 →
Same concept, more angles
1 more way this is tested on TF-004
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which TWO of the following statements about Terraform state are correct? (Choose two.)
easy- ✓ A.Terraform state can be stored remotely using backends like S3 or Azure Storage.
- B.Terraform state can be shared across team members using a local file.
- ✓ C.Terraform state is stored locally by default in a file named terraform.tfstate.
- D.Terraform state is always encrypted at rest by default.
- ✓ E.Terraform state contains sensitive information such as resource passwords.
Why A: Terraform state is stored locally by default in terraform.tfstate, and can be shared via remote backends like S3. State is not encrypted by default and may contain sensitive data.
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.