nerdexam
HashiCorp

TA-002-P · Question #26

When should you use the force-unlock command?

The correct answer is C. Automatic unlocking failed. terraform force-unlock should only be used when automatic unlocking has failed - meaning a previous Terraform run crashed or was interrupted, leaving a stale lock in the backend that did not get released automatically. It should not be used simply because you cannot acquire a…

Implement and maintain state

Question

When should you use the force-unlock command?

Options

  • AYou see a status message that you cannot acquire the lock
  • BYou have a high priority change
  • CAutomatic unlocking failed
  • DYour apply failed due to a state lock

How the community answered

(63 responses)
  • A
    2% (1)
  • B
    3% (2)
  • C
    89% (56)
  • D
    6% (4)

Explanation

terraform force-unlock should only be used when automatic unlocking has failed - meaning a previous Terraform run crashed or was interrupted, leaving a stale lock in the backend that did not get released automatically. It should not be used simply because you cannot acquire a lock (another operation may be legitimately running), because you have a high-priority change (never a valid reason to bypass safety), or because an apply failed (the lock is typically released on failure). Misusing force-unlock when another process is actively running can corrupt state.

Topics

#Terraform CLI#State locking#force-unlock#Troubleshooting

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice