TF-004 Understand Terraform's purpose Practice Question
A team uses a remote backend (S3) with state locking via DynamoDB. One team member runs terraform apply and it fails mid-way. Another team member immediately tries to run terraform plan. What is likely to happen?
⚠ Common exam trap
A common misconception is that a failed Terraform operation automatically releases the state lock, leading candidates to incorrectly choose Option A, when in fact the lock persists until explicit release or timeout.
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 plan will fail with an error indicating the state is locked.
Terraform's remote backend with DynamoDB state locking acquires a lock at the start of `terraform apply` and does not release it until the operation completes or is explicitly unlocked. If the apply fails mid-way, the lock remains held (it is not automatically released on failure). Therefore, when another team member immediately runs `terraform plan`, the plan command will attempt to acquire the lock, fail, and return an error indicating the state is locked.
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 plan will run successfully because the lock is automatically released after failure.
Why it's wrong here
Terraform state locking, especially with remote backends like S3 and DynamoDB, is designed to prevent concurrent operations. A lock is not automatically released upon a failure; its persistence ensures that a potentially incomplete or crashed operation does not leave the state vulnerable to another concurrent write. Releasing the lock typically requires explicit action, such as `terraform force-unlock`, or waiting for a configured timeout.
- ✗
The plan will run but the state file will be corrupted.
Why it's wrong here
Terraform's remote state management, particularly when coupled with state locking, is engineered for high consistency and atomicity. If an operation fails while a lock is held, the state file in the remote backend is either not updated or is rolled back to its last known consistent version. This design prevents state file corruption by ensuring that only fully successful operations commit changes, maintaining data integrity.
- ✓
The plan will fail with an error indicating the state is locked.
Why this is correct
When a Terraform state is locked, any subsequent `terraform plan` command will fail with an explicit error message indicating that the state is currently locked. This mechanism, facilitated by DynamoDB for S3 backends, prevents concurrent operations that could lead to inconsistent infrastructure or state file corruption. The plan cannot proceed because it requires a stable, consistent view of the state, which the lock protects.
- ✗
The plan will run successfully and show any partial changes.
Why it's wrong here
A `terraform plan` command cannot run successfully if the state is locked, as the lock explicitly prevents any operation that interacts with the state from proceeding. Terraform does not generate a plan showing 'partial changes' in this scenario; instead, it halts execution immediately upon detecting the active lock. The lock ensures that the plan is always generated against a complete and consistent state, or it fails to generate one at all.
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
This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.