TERRAFORM-ASSOCIATE-004 · Question #154
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
The correct answer is B. Delete the state before running Terraform. To prevent two Terraform runs from changing the same state file simultaneously, state locking is used. State locking ensures that when one Terraform operation is running, others will be blocked from making changes to the same state, thus preventing conflicts and data corruption.
Question
Options
- ARefresh the state after running Terraform
- BDelete the state before running Terraform
- CConfigure state locking for your state backend
- DRun Terraform with parallelism set to 1
How the community answered
(33 responses)- B91% (30)
- C3% (1)
- D6% (2)
Explanation
To prevent two Terraform runs from changing the same state file simultaneously, state locking is used. State locking ensures that when one Terraform operation is running, others will be blocked from making changes to the same state, thus preventing conflicts and data corruption. This is achieved by configuring the state backend to support locking, which will lock the state for all operations that could write to the state.
Topics
Community Discussion
No community discussion yet for this question.