A team is using a remote backend in Terraform Cloud. After a failed apply, the state file is locked. The team lead wants to unlock the state immediately. What should be done?
Trap 1: Delete the state file from the backend and reinitialize
Deleting the state file is destructive and can cause data loss.
Trap 2: Manually edit the state file to remove the lock
Editing the state file directly is risky and not recommended.
Trap 3: Run terraform unlock
There is no terraform unlock command; the correct command is terraform force-unlock.
- A
Delete the state file from the backend and reinitialize
Why wrong: Deleting the state file is destructive and can cause data loss.
- B
Run terraform force-unlock with the lock ID
The terraform force-unlock command with the lock ID manually releases the lock.
- C
Manually edit the state file to remove the lock
Why wrong: Editing the state file directly is risky and not recommended.
- D
Run terraform unlock
Why wrong: There is no terraform unlock command; the correct command is terraform force-unlock.