When to Force Unlock
Terraform locks state during plan/apply to prevent concurrent modifications. If a run is interrupted (timeout, crash, network failure), the lock may persist and block future runs.
Force unlock when:
- A run timed out or failed mid-apply
- The state is locked and no run is in progress
- You’ve confirmed no other process is modifying the state
Warning: Force unlocking while another process is actively writing state can cause corruption. Only force unlock when you’re certain no other process holds the lock.
Triggering a Force Unlock
POST /workspaces/{id}/force-unlock
{ "lock_id": "optional-lock-id" }
The lock_id is optional. If provided, it’s passed to the unlock command.
What Happens
- Forgecroft checks for concurrent force-unlock runs (409 if one is already queued or in progress)
- Finds the most recent timed out or failed run for audit context
- Creates a standalone unlock run (not linked to any changeset)
- The unlock run releases the state lock
- Any other
in_progressrun for the workspace is forced totimed_out
Response
{
"unlock_run_id": "uuid",
"timed_out_run_id": "uuid"
}
unlock_run_id— The ID of the unlock run that was createdtimed_out_run_id— The ID of the run that was forced to timed_out (if any)
Unlock Run Status
The unlock run has run_type: "unlock" and action: "forceunlock". It reaches unlocked status on success.
Related API Endpoints
POST /workspaces/{id}/force-unlock— Trigger a force unlockGET /workspaces/{workspaceId}/runs/{runId}— View unlock run status