capabilities.work

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.

  1. List the workspace's runs filtered to the supplied in-flight status, newest first, taking only the most recent match.
  2. Read the matched run to confirm it is genuinely still in flight and has not settled on its own since the list call.
  3. Cancel the in-progress run, recording why it was cancelled so the run history explains the intervention.
  4. Poll the run until the cancellation is reflected in its status, repeating while the run is still winding down.
  5. 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.