Why is my Step Functions state machine stuck in the DELETING status?

2 minute read

My AWS Step Functions state machine is stuck in the DELETING status and I want to know my next steps.

Short description

The DeleteStateMachine API action asynchronously deletes a Step Functions state machine and the state machine's versions and aliases. You can't stop a state machine's deletion after you call DeleteStateMachine and the status switches to DELETING. Yet, a state machine might get stuck in DELETING when an execution is in a Wait state or a task is waiting for a response.

The state machine deletion process depends on whether your machine follows Standard or Express Workflows. Deletions typically get stuck in state machines with Standard Workflows, where executions fail with the following error:

{"Type": "ExecutionFailed", "ExecutionFailedEventDetails": {"Error": States.Runtime", "Cause": "State machine testing-delete has been deleted."}}


To delete a Standard Workflow state machine that's stuck in DELETING status, complete the following steps:

  1. List all running executions.
  2. Stop all running executions.

The following example Python code stops running executions:

Note: In your command, replace EXAMPLE_ARN with your state machine's ARN.

sf = boto3.client('stepfunctions')

runningExecutions = sf.list_executions(

executions = runningExecutions['executions']

if not executions:
    print("No running executions")
    for exec in executions:
        executionArn = exec['executionArn']
        response = sf.stop_execution(executionArn=executionArn)
      except Exception as err:
        print(f" Couldn't stop an execution due to the following error :  {err=}")
    print("All running executions have been aborted.")

Note: State machines with Express Workflows don't support the ListExecutions and StopExecutions APIs.

Protect your state machine from accidental deletion

You can't back up a state machine in Step Functions, but you can protect your state machine with the following methods:

AWS OFFICIALUpdated 5 months ago