Search code examples
aws-sdkaws-step-functions

What is the alternative to listExecutions since this API action is not supported by EXPRESS state machines?


I've implemented an EXPRESS state machine and I'm attempting to retrieve the list of executions of a state machine. Below is my code snippet:

const stepFunction = new SFN({ region: REGION });
const listExecutionsInput = {
                stateMachineArn: STATE_MACHINE_ARN,
                statusFilter: ExecutionStatus.RUNNING,
            };

const runningStateMachines = await stepFunction.listExecutions(listExecutionsInput);

However, it throws the following error:

{
    message: 'This operation is not supported by this type of state machine',
    error: {
        name: 'StateMachineTypeNotSupported',
        $fault: 'client',
        $metadata: {
            httpStatusCode: 400,
            requestId: 'ciefq5881-6713-4662-b8fe-e0ddqa9ef4d1',
            attempts: 1,
            totalRetryDelay: 0,
        },
        __type: 'com.amazonaws.swf.service.v2.model#StateMachineTypeNotSupported',
    },
    platform: 'Unknown',
    releaseId: 'Unknown',
    incomingHttpRequest: {},
    fatal: true,
}

Upon further investigation, I discovered that the listExecutions API action is not supported by EXPRESS state machines. I'm wondering if there's an alternative API action that can provide at least the names of recent executions. Could you please advise?

For more context, you can refer to the documentation: https://docs.aws.amazon.com/step-functions/latest/apireference/API_ListExecutions.html


Solution

  • This is one of the key differences between Standard and Express Workflows. You can read more about these here: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-standard-vs-express.html

    Express Workflows does not maintain a list of executions in the Step Functions service. However, you can optionally enable logging of Execution History to CloudWatch Logs then query for this information from your logs (e.g., using CloudWatch Logs Insights). The Step Functions console includes an option to present this information from your logs that you can also enable (more details here).