Back to Aws Doc Sdk Examples

Step Functions code examples for the SDK for Python

python/example_code/stepfunctions/README.md

latest4.4 KB
Original Source
<!--Generated by WRITEME on 2023-04-12 00:07:52.202277 (UTC)-->

Step Functions code examples for the SDK for Python

Overview

Shows how to use the AWS SDK for Python (Boto3) to work with AWS Step Functions.

<!--custom.overview.start--> <!--custom.overview.end-->

Step Functions makes it easy to coordinate the components of distributed applications as a series of steps in a visual workflow.

⚠ Important

  • Running this code might result in charges to your AWS account.
  • Running the tests might result in charges to your AWS account.
  • We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
  • This code is not tested in every AWS Region. For more information, see AWS Regional Services.
<!--custom.important.start--> <!--custom.important.end-->

Code examples

Prerequisites

For prerequisites, see the README in the python folder.

Install the packages required by these examples by running the following in a virtual environment:

python -m pip install -r requirements.txt
<!--custom.prerequisites.start--> <!--custom.prerequisites.end-->

Get started

Single actions

Code excerpts that show you how to call individual service functions.

Scenarios

Code examples that show you how to accomplish a specific task by calling multiple functions within the same service.

Cross-service examples

Sample applications that work across multiple AWS services.

Run the examples

Instructions

<!--custom.instructions.start--> <!--custom.instructions.end-->

Hello Step Functions

This example shows you how to get started using Step Functions.

python hello.py

Get started with state machines

This example shows you how to do the following:

  • Create an activity.
  • Create a state machine from an Amazon States Language definition that contains the previously created activity as a step.
  • Run the state machine and respond to the activity with user input.
  • Get the final status and output after the run completes, then clean up resources.
<!--custom.scenario_prereqs.sfn_Scenario_GetStartedStateMachines.start--> <!--custom.scenario_prereqs.sfn_Scenario_GetStartedStateMachines.end-->

Start the example by running the following at a command prompt:

python get_started_state_machines.py
<!--custom.scenarios.sfn_Scenario_GetStartedStateMachines.start--> <!--custom.scenarios.sfn_Scenario_GetStartedStateMachines.end-->

Tests

⚠ Running tests might result in charges to your AWS account.

To find instructions for running these tests, see the README in the python folder.

<!--custom.tests.start--> <!--custom.tests.end-->

Additional resources

<!--custom.resources.start--> <!--custom.resources.end-->

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0