SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 101 Java
<!--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](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
<!--custom.important.start-->
<!--custom.important.end-->
## Code examples
### Prerequisites
For prerequisites, see the [README](../../README.md#Prerequisites) 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
* [Hello Step Functions](hello.py#L4) (`ListStateMachines`)
### Single actions
Code excerpts that show you how to call individual service functions.
* [Create a state machine](state_machines.py#L28) (`CreateStateMachine`)
* [Create an activity](activities.py#L31) (`CreateActivity`)
* [Delete a state machine](state_machines.py#L138) (`DeleteStateMachine`)
* [Delete an activity](activities.py#L118) (`DeleteActivity`)
* [Describe a state machine](state_machines.py#L75) (`DescribeStateMachine`)
* [Describe a state machine run](state_machines.py#L118) (`DescribeExecution`)
* [Get task data for an activity](activities.py#L73) (`GetActivityTask`)
* [List activities](activities.py#L51) (`ListActivities`)
* [List state machines](state_machines.py#L53) (`ListStateMachines`)
* [Send a success response to a task](activities.py#L95) (`SendTaskSuccess`)
* [Start a state machine run](state_machines.py#L95) (`StartExecution`)
### Scenarios
Code examples that show you how to accomplish a specific task by calling multiple
functions within the same service.
* [Get started with state machines](get_started_state_machines.py)
### Cross-service examples
Sample applications that work across multiple AWS services.
* [Create a messenger application](../../cross_service/stepfunctions_messenger)
## 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](../../README.md#Tests)
in the `python` folder.
<!--custom.tests.start-->
<!--custom.tests.end-->
## Additional resources
* [Step Functions Developer Guide](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)
* [Step Functions API Reference](https://docs.aws.amazon.com/step-functions/latest/apireference/Welcome.html)
* [SDK for Python Step Functions reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/stepfunctions.html)
<!--custom.resources.start-->
<!--custom.resources.end-->
---
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0