Search code examples
aws-cloudformationaws-step-functionsaws-event-bridge

Is there a way to customized a state machine execution name?


By default each AWS Step Function execution name is randomly generated. I would like to add a prefix to each randomly generated name. I couldn't find a way to do this anywhere in the documentation. The way I would envision doing this is in the CloudFormation template that defines the EventBridge rule, but I am open to suggestions if there is a way that I am currently unaware of.

Has anyone else been able to do this, or am I out of luck?


Solution

  • If you are calling startExecution then there is a way that I mention bellow. But seems like your question is related to calling Step Functions from other service (Maybe EventBridge) that my answer is not covering it. For that if there is no direct way, you can call a Lambda function and from Lambda call Step Function startExecution.

    StartExecution accept this:

    {
       "input": "string",
       "name": "string",
       "stateMachineArn": "string",
       "traceHeader": "string"
    }
    

    And name is what you are looking for:

    The name of the execution. This name must be unique for your AWS account, region, and state machine for 90 days. For more information, see Limits Related to State Machine Executions in the AWS Step Functions Developer Guide.

    A name must not contain:

    white space

    brackets < > { } [ ]

    wildcard characters ? *

    special characters " # % \ ^ | ~ ` $ & , ; : /

    control characters (U+0000-001F, U+007F-009F)

    To enable logging with CloudWatch Logs, the name should only contain 0-9, A-Z, a-z, - and _.

    Link: https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html

    You have similar option when starting the Execution from AWS CLI, Console,...