nerdexam
HashiCorp

TA-002-P · Question #160

You are using a terraform operation that writes state. Unfortunately automatic state unlocking has failed for that operation. Which of the below commands can be used to remove the already acquired…

The correct answer is B. terraform force-unlock. The correct command is terraform force-unlock. When a Terraform operation that writes state (like terraform apply) fails mid-execution, it may leave a lock on the state file to prevent concurrent modifications. If automatic unlocking also fails, you must manually release it…

Implement and maintain state

Question

You are using a terraform operation that writes state. Unfortunately automatic state unlocking has failed for that operation. Which of the below commands can be used to remove the already acquired lock on the state?

Options

  • Aterraform unlock
  • Bterraform force-unlock
  • Cterraform state unlock
  • DNone of the above

How the community answered

(32 responses)
  • B
    91% (29)
  • C
    6% (2)
  • D
    3% (1)

Explanation

The correct command is terraform force-unlock. When a Terraform operation that writes state (like terraform apply) fails mid-execution, it may leave a lock on the state file to prevent concurrent modifications. If automatic unlocking also fails, you must manually release it using terraform force-unlock <LOCK_ID>. The lock ID is shown in the error message when the lock was acquired. Options A (terraform unlock) and C (terraform state unlock) are not valid Terraform commands.

Topics

#Terraform CLI#State management#State locking#Troubleshooting

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice