nerdexam
HashiCorp

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.

Submitted by kev92· Apr 18, 2026Manage Terraform State

Question

Which of these actions will prevent two Terraform runs from changing the same state file at the same time?

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)
  • B
    91% (30)
  • C
    3% (1)
  • D
    6% (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

#Terraform State#State Management#Concurrency#State File

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-004 Practice