Find and Cancel a Stuck Run
A 5-step recipe with Terraform. We can help you get access.
Recipe · 5 steps
Find and Cancel a Stuck Run
with Terraform · IT Infrastructure Management
Cancel an in-progress run on a workspace and release the workspace lock.
- List the workspace's runs filtered to the supplied in-flight status, newest first, taking only the most recent match.
- Read the matched run to confirm it is genuinely still in flight and has not settled on its own since the list call.
- Cancel the in-progress run, recording why it was cancelled so the run history explains the intervention.
- Poll the run until the cancellation is reflected in its status, repeating while the run is still winding down.
- Unlock the workspace so the next run can be queued, since a cancelled run can leave the workspace locked behind it.
What you'll need to have ready
- workspaceId: The workspace identifier holding the stuck run.
- runStatusFilter: The run status to hunt for (e.g. "planning", "applying", "pending").
- cancelComment: The comment recorded against the cancellation for the audit trail.
For your developer
Arazzo workflow terraform:cancel-stuck-run, 5 operations: ListWorkspaceRuns → GetRun → CancelRun → GetRun → UnlockWorkspace. Specs on APIs.io.