user2974951
user2974951

Reputation: 10385

Python boto3 step function list executions filter

I am trying to retrieve a specific step function execution input in the past using the list_executions and describe_execution functions in boto3, first to retrieve all the calls and then to get the execution input (I can't use describe_execution directly as I do not know the full state machine ARN). However, list_executions does not accept a filter argument (such as "name"), so there is no way to return partial matches, but rather it returns all (successful) executions.

The solution for now has been to list all the executions and then loop over the list and select the right one. The issue is that this function can return a max 1000 newest records (as per the documentation), which will soon be an issue as there will be more than 1000 executions and I will need to get old executions.

Is there a way to specify a filter in the list_executions/describe_execution function to retrieve execution partially filtered, for ex. using prefix?

import boto3
sf=boto3.client("stepfunctions").list_executions(
    stateMachineArn="arn:aws:states:something-something",
    statusFilter="SUCCEEDED",
    maxResults=1000
)

Upvotes: 0

Views: 4157

Answers (1)

fedonev
fedonev

Reputation: 25739

You are right that the SFN APIs like ListExecutions do not expose other filtering options. Nonetheless, here are two ideas to make your task of searching execution inputs easier:

  1. Use the ListExecutions Paginator to help with looping through the response items.
  2. If you know in advance which inputs are of interest, add a Task to the State Machine to persist execution inputs and ARNs to, say, a DynamoDB table, in a manner that makes subsequent searches easier.

Upvotes: 1

Related Questions