The Terraform force-unlock command was executed without specifying a lock ID. This command requires a unique lock ID as an argument to safely unlock your state file.
Terraform's force-unlock command is used to manually release state locks that have become stuck or orphaned. This error occurs when you attempt to run `terraform force-unlock` without providing the required lock ID argument. The lock ID is a unique identifier that Terraform displays when a lock is held, and it's required to prevent accidental unlocking of the wrong state file. This safety mechanism ensures that only intentional force-unlocks occur and helps protect against data corruption or concurrent modifications to your infrastructure state.
When you encounter a Terraform state lock, the error message will display the lock information including the unique lock ID. Look for a message similar to:
Error acquiring the state lock: ConditionalCheckFailedException:
Lock ID: a1b2c3d4-5678-9101-1234-567890abcdefThe lock ID is the unique identifier shown in the error output. If you've already cleared the screen, check the .tfstate.lock file in your state backend for the lock information.
Once you have the lock ID, run the force-unlock command with it as an argument:
terraform force-unlock a1b2c3d4-5678-9101-1234-567890abcdefReplace a1b2c3d4-5678-9101-1234-567890abcdef with your actual lock ID. Terraform will prompt you to confirm the unlock operation.
When prompted, confirm that you want to proceed with the force-unlock:
Do you really want to unlock the state?
[no] > yesType yes and press Enter. If you want to skip the confirmation prompt, you can add the -force flag:
terraform force-unlock a1b2c3d4-5678-9101-1234-567890abcdef -forceAfter the command completes successfully, verify that the state lock is cleared by attempting a regular Terraform operation:
terraform planIf the plan runs without lock errors, the force-unlock was successful. The state file is now accessible for new operations.
Force-unlock should only be used as a last resort after confirming that no other Terraform operations are running. Using force-unlock while another process is modifying the state can cause state corruption or data loss. If you're using Terraform Cloud or Terraform Enterprise, the force-unlock CLI command is not available by design—instead, use the UI to unlock workspaces through the Settings > Locking menu. For remote backends like S3, DynamoDB, or Consul, ensure you have the correct IAM permissions or access credentials to interact with the lock storage mechanism. The lock ID is stored in your backend's lock tracking system and may persist there even after the unlock command succeeds, so don't rely on the lock file existing to verify the unlock.
Error: Error rendering template: template not found
How to fix "template not found" error in Terraform
Error: Error generating private key
How to fix 'Error generating private key' in Terraform
Error creating Kubernetes Service: field is immutable
How to fix "field is immutable" errors in Terraform
Error: Error creating local file: open: permission denied
How to fix "Error creating local file: permission denied" in Terraform
Error: line endings have changed from CRLF to LF
Line endings have changed from CRLF to LF in Terraform