Save and run your Step Functions workflow - AWS Step Functions

Save and run your Step Functions workflow

Now that you’ve configured all of the resources in the prototype, you can save your state machine and run the workflow, also known as a workflow execution.

Step 1: Review the auto-generated state machine definition and save the state machine

As you drag and drop states from the Flow tab onto the canvas in Workflow Studio to build the workflow prototype, Step Functions automatically composes the Using Amazon States Language to define Step Functions workflows (ASL) definition of your workflow in real-time. You can edit this definition as required in the Code editor.

To review the ASL definition and save the state machine
  1. (Optional) Choose Definition on the Inspector panel to view the state machine's Amazon States Language (ASL) definition, which is automatically generated based on your selections in the Actions and Flow tabs and Inspector panel.

    Tip

    To edit the definition, you can open the code editor by choosing Code on top of the page. For now, continue with the auto-generated definition.

  2. Specify a name for your state machine. To do this, choose the edit icon next to the default state machine name of MyStateMachine. Then, in State machine configuration, specify a name in the State machine name box.

    Enter the name CreditCardWorkflow.

  3. (Optional) In State machine configuration, specify other workflow settings, such as state machine type and its execution role.

    For now, keep all the default selections in State machine settings.

    Note

    (Optional) Step Functions automatically creates an execution role for the state machine with the least privileges required to invoke the RandomNumberforCredit Lambda function and publish to the Amazon SNS topic.

    If you've previously created an IAM role with the correct permissions for your state machine and want to use it, in Permissions, select Choose an existing role, and then select a role from the list. Or select Enter a role ARN and then provide an ARN for that IAM role.

  4. In the Confirm role creation dialog box, choose Confirm to continue.

    You can also choose View role settings to go back to State machine configuration.

    Note

    If you delete the IAM role that Step Functions creates, Step Functions can't recreate it later. Similarly, if you modify the role (for example, by removing Step Functions from the principals in the IAM policy), Step Functions can't restore its original settings later.

Step 2: Add the remaining IAM policies

Because Step Functions doesn't auto-generate the permissions to invoke the Lambda functions used in the Parallel state, you need to add the necessary policy.

To add the remaining policy
  1. On the CreditCardWorkflow page, choose the IAM role for your state machine to navigate to the IAM console. You’ll add the necessary permissions for the remaining Lambda functions on this page.

  2. Choose Add permissions, and then choose Attach policies.

  3. In the search box, type AWSLambdaRole and then press Enter.

  4. Choose AWSLambdaRole and then choose Attach policies. This policy is now added to the execution role of your state machine. This policy lets you invoke any Lambda function in your state machine.

Step 3: Run the state machine

State machine executions are instances where you run your workflow to perform tasks.

To execute the state machine
  1. On the CreditCardWorkflow page, choose Start execution.

    The Start execution dialog box is displayed.

  2. In the Start execution dialog box, do the following:

    1. (Optional) Enter a custom execution name to override the generated default.

      Non-ASCII names and logging

      Step Functions accepts names for state machines, executions, activities, and labels that contain non-ASCII characters. Because such characters will not work with Amazon CloudWatch, we recommend using only ASCII characters so you can track metrics in CloudWatch.

      Note

      You don’t need to provide any input to execute this state machine. But you can specify an execution input, if required, in the Input area of the Start execution dialog box for other state machines. For an example of how to provide execution input to a state machine, see Step 4: Start a new execution of the Learn to use the AWS Step Functions Workflow Studio tutorial.

    2. Choose Start execution.

  3. The Step Functions console directs you to a page that's titled with your execution ID. This page is known as the Execution Details page. On this page, you can review the execution results as the execution progresses or after it's complete.

    To review the execution results, choose individual states on the Graph view, and then choose the individual tabs on the Step details pane to view each state's details including input, output, and definition respectively. For details about the execution information you can view on the Execution Details page, see Execution details overview.

Next steps

In the next topic, Configure input and output, you’ll learn how to filter and manipulate data that passes from state to state.