TA-002-P · Question #448
What does state locking accomplish?
The correct answer is C. Blocks Terraform commands from modifying the state file. State locking prevents concurrent Terraform operations from simultaneously modifying the state file, which could cause corruption or inconsistent state. When a terraform apply, plan, or destroy begins, Terraform acquires a lock on the state backend (e.g., a DynamoDB table for…
Question
What does state locking accomplish?
Options
- ACopies the state file from memory to disk
- BEncrypts any credentials stored within the state file
- CBlocks Terraform commands from modifying the state file
- DPrevents accidental deletion of the state file
How the community answered
(31 responses)- A3% (1)
- B6% (2)
- C90% (28)
Explanation
State locking prevents concurrent Terraform operations from simultaneously modifying the state file, which could cause corruption or inconsistent state. When a terraform apply, plan, or destroy begins, Terraform acquires a lock on the state backend (e.g., a DynamoDB table for S3 backends). Any other Terraform process attempting to run against the same state will wait or fail until the lock is released. This is critical in team environments where multiple engineers or CI/CD pipelines might trigger Terraform simultaneously. It does not encrypt credentials (B), copy state to disk (A), or prevent deletion (D).
Topics
Community Discussion
No community discussion yet for this question.