Using Workflow Studio - Amazon Step Functions
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using Workflow Studio

Learn to create, edit, and run workflows using Step Functions Workflow Studio. After your workflow is ready, you can export it. You can also use Workflow Studio for rapid prototyping.

Create a workflow

In Workflow Studio, you can either choose a starter template, or choose a blank template to create a workflow from scratch. For blank templates, you can use the Design or Code mode to create your workflow.

A starter template is a ready-to-run sample project that automatically creates the workflow proptotype and definition, and deploys all the related Amazon resources that your project needs to your Amazon Web Services account. You can use these starter templates to deploy and run them as is, or use the workflow prototypes to build on them. For more information about starter templates, see Sample projects for Step Functions.

Create a workflow using starter templates

  1. Open the Step Functions console and choose Create state machine.

  2. In the Choose a template dialog box, do one of the following to choose a sample project, for example, the Task Timer sample project:

    • Type Task Timer in the Search by keyword box, and then choose Task Timer from the search results that are returned.

    • Browse through the sample projects listed under All on the right pane, and then choose Task Timer.

  3. Choose Next to continue.

  4. Step Functions lists the Amazon Web Services used in the sample project you selected. It also shows a workflow graph for the sample project. Deploy this project to your Amazon Web Services account or use it as a starting point for building your own projects. Based on how you want to proceed, choose Run a demo or Build on it.

  5. Choose Use template to continue with your selection.

  6. Do one of the following:

    • If you selected Build on it, Step Functions creates the workflow prototype for the sample project you selected. Step Functions doesn't deploy the resources listed in the workflow definition. In Design mode, drag and drop states from the States browser to continue building your workflow protoype. Or switch to the Code mode for updating the Amazon States Language (ASL) definition of your workflow.

      Important

      Remember to update the placeholder Amazon Resource Name (ARN) for the resources used in the sample project before you run your workflow.

    • If you selected Run a demo, Step Functions creates a read-only sample project which uses an Amazon CloudFormation template to deploy the Amazon resources listed in that template to your Amazon Web Services account.

      Tip

      To view the state machine definition of the sample project, choose Code.

      When you're ready, choose Deploy and run to deploy the sample project and create the resources.

      Note

      It can take up to 10 minutes for these resources and related IAM permissions to be created. While your resources are being deployed, you can open the CloudFormation Stack ID link to see which resources are being provisioned.

      Important

      Standard charges apply for each service used in the CloudFormation template.

Create a workflow using a blank template

  1. Open the Step Functions console.

  2. Choose Create state machine.

  3. In the Choose a template dialog box, select Blank.

  4. Choose Select. This opens Workflow Studio in Design mode.

    You can now start designing your workflow in Design mode or writing your workflow definition in Code mode.

  5. Choose Config to manage the configuration of your workflow in the Config mode. For example, provide a name for your workflow and choose its type.

Design a workflow

If you know the name of the state you want to add, use the search box at the top of the States browser to find that state in the Actions and Flow tabs of the Design mode.


          Step Functions Workflow Studio search

Otherwise, choose a state from the states browser and drag and drop it onto the canvas, placing it where you want in your workflow. You can also reorder states in your workflow by dragging them to a different location in your workflow. As you drag a state onto the canvas, a line appears wherever you can drop it in your workflow. After a state is dropped onto the canvas, its code is auto-generated and added inside your workflow definition. To see the definition, turn on the Definition toggle on the Inspector panel. To make edits to your workflow definition, choose the Code mode that offers an integrated code editor.


          Step Functions Workflow Studio add state to canvas

After you drop a state onto the canvas, you can configure it in the Inspector panel on the right. This panel contains the Configuration, Input, Output, and Error Handling tabs for each of the state or API action that you place on the canvas. You configure the states you include in your workflows in the Configuration tab. For example, the Configuration tab for Lambda Invoke API action consists of the following options:


          Configuration options
  1. The State name identifies the state. You can use your own name or accept the default generated name.

  2. The API shows the API action used by the state.

  3. The Integration type dropdown list provides options to choose the type of service integrations available in Step Functions. The integration type you choose is used to call API actions of a specific Amazon Web Service from your workflow.

  4. The Function name provides options to:

    • Enter a function name: You can enter your function name or its ARN.

    • Get function name at runtime from state input: You can use this option to dynamically get the function name from the state input based on the path you specify.

    • Select function name: You can directly select from the functions available in your account and region.

  5. The Payload lets you select from the following options:

    • Use state input as payload: You can use this option to pass the state’s input as the payload provided to your Lambda function.

    • Enter your own payload: You can use this option to construct a JSON object to pass as the payload to your Lambda function. This JSON can include both static values and values selected from the state input.

    • No payload: You can use this option if you don’t want to pass any payload to your Lambda function.

  6. (Optional) Some states will have an option to select Wait for task to complete or Wait for callback. When available, these options select one of the following service integration patterns:

    • No option selected: Step Functions will use the Request Response integration pattern. Step Functions will wait for an HTTP response and then progress to the next state. Step Functions will not wait for a job to complete. When no options are available, the state will use this pattern.

    • Wait for task to complete: Step Functions will use the Run a Job (.sync) integration pattern.

    • Wait for callback: Step Functions will use the Wait for a Callback with the Task Token integration pattern.

  7. (Optional) To access resources configured in different Amazon Web Services accounts within your workflows, Step Functions provides cross-account access. IAM role for cross-account access provides options to:

    • Provide IAM role ARN: Specify the IAM role that contains appropriate resource access permissions. These resources are available in a target account, which is an Amazon Web Services account to which you make cross-account calls.

    • Get IAM role ARN at runtime from state input: Specify a reference path to an existing key-value pair in the state’s JSON input which contains the IAM role.

  8. Next state lets you to select the state you want to transition to next.

  9. (Optional) The Comment field can be used to add your own comment. It will not affect the workflow, but can be used to annotate your workflow.

Some states will have more generic configuration options. For example, the Amazon ECS RunTask state configuration contains an API Parameters field populated with placeholder values.


          Configuration options for Amazon ECS RunTask state

For these states, you can replace the placeholder values with configurations that are suited to your needs.

To delete a state, you can use backspace, right-click and choose Delete state, or choose Delete on the Design toolbar.


          Delete state

As your workflow grows, it may not fit in the canvas. You can:

  1. Use the controls on the side panels to resize or close the panels.

  2. Use the Design toolbar controls at the top of the Canvas to zoom the workflow graph in or out.


          Canvas controls

Run your workflow

After you create or edit your workflow with the Workflow Studio, you can run it and view its execution in the Step Functions console.

To run a workflow in Workflow Studio
  1. In the Design, Code, or Config mode, choose Execute.

    The Start execution dialog box opens in a new tab.

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

    1. (Optional) To identify your execution, you can specify a name for it in the Name box. By default, Step Functions generates a unique execution name automatically.

      Note

      Step Functions allows you to create names for state machines, executions, and activities, and labels that contain non-ASCII characters. These non-ASCII names don't work with Amazon CloudWatch. To ensure that you can track CloudWatch metrics, choose a name that uses only ASCII characters.

    2. (Optional) In the Input box, enter input values in JSON format to run your workflow.

    3. Choose Start execution.

    4. 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 page – Interface overview.

Edit your workflow

You can edit an existing workflow visually in the Design mode of Workflow Studio. You can also edit the workflow definition in Code mode of Workflow Studio.

To edit an existing workflow:

  1. Open the Step Functions console.

  2. On the State machines page, choose the workflow you want to edit.

  3. On the State machine detail page, choose Edit.

  4. The workflow opens in Design mode of Workflow Studio. Edit the workflow as required.

    
              Edit the workflow in Design mode
    Note

    If you see errors in your workflow, you must fix them in Design mode. You can't switch to the Code or Config mode if any errors exist in your workflow.

  5. (Optional) Choose the Code button to view or edit the workflow definition in Workflow Studio.

    
              View or edit the workflow in Code mode
  6. When you are done, choose Save to save your updated workflow.

  7. (Optional) To run your updated workflow, choose Execute. The Start execution dialog box opens in a new tab.

Export your workflow

You can export your workflow's Amazon States Language (ASL) definition and your workflow graph:

  1. Choose your workflow in the Step Functions console.

  2. On the State machine detail page, choose Edit.

  3. (Optional) Your workflow opens in Design mode of Workflow Studio. Edit your workflow in Design mode or switch to the Code mode.

  4. Choose the Actions dropdown button, and then do one or both of the following:

    • To export the workflow graph to an SVG or PNG file, under Export graph, select the format you want.

    • To export the workflow definition as a JSON or YAML file, under Export definition, select the format you want.

Create your workflow prototype

You can use Workflow Studio to create prototypes of new workflows that contain placeholder resources. You can also build your workflows using Workflow Studio in Application Composer. To create a prototype:

  1. Sign in to the Step Functions console.

  2. Choose Create state machine.

  3. In the Choose a template dialog box, select Blank.

  4. Choose Select. This opens Workflow Studio in Design mode.

  5. The Design mode of Workflow Studio opens. Design your workflow in Workflow Studio. To include placeholder resources:

    1. Choose the state for which you want to include a placeholder resource, and then in Configuration:

      • For Lambda Invoke states, choose Function name, then choose Enter function name. You can also enter a custom name for your function.

      • For Amazon SQS Send Message states, choose Queue URL, then choose Enter queue URL. Enter a placeholder queue URL.

      • For Amazon SNS Publish states, from Topic, choose a topic ARN.

      • For all other states listed under Actions, you can use the default configuration.

      Note

      If you see errors in your workflow, you must fix them in Design mode. You can't switch to the Code or Config mode if any errors exist in your workflow.

    2. (Optional) To view the auto-generated ASL definition of your workflow, choose Definition.

    3. (Optional) To update the workflow definition in Workflow Studio, choose the Code button.

      Note

      If you see errors in your workflow definition, you must fix them in Code mode. You can't switch to the Design or Config mode if any errors exist in your workflow definition.

  6. (Optional) To edit the state machine name, choose the edit icon next to the default state machine name of MyStateMachine and specify a name in the State machine name box.

    You can also switch to the Config mode to edit the default state machine name.

  7. Specify your workflow settings, such as state machine type and its execution role.

  8. Choose Create.

You've now created a new workflow with placeholder resources that can be used to prototype. You can export your workflow definition and the workflow graph.

  • To export your workflow definition as a JSON or YAML file, in the Design or Code mode, choose the Actions dropdown button. Then, under Export definition, select the format you want to export. You can use this exported definition as the starting point for local development with the Amazon Toolkit for Visual Studio Code.

  • To export your workflow graph to an SVG or PNG file, in the Design or Code mode, choose the Actions dropdown button. Then, under Export definition, select the format you want.