python/cross_service/stepfunctions_messenger/README.md
Shows how to use the AWS SDK for Python (Boto3) with AWS Step Functions to create and run state machines.
Deploy prerequisite resources by running the example script with the deploy flag at
a command prompt.
python stepfunctions_demo.py deploy
Run the usage example with the demo flag at a command prompt.
python stepfunctions_demo.py demo
Destroy example resources by running the script with the destroy flag at a command
prompt.
python stepfunctions_demo.py destroy
The example contains the following files.
state_definitions.py
Constructs state definitions used for the demonstration by inserting resource identifiers that are retrieved from the CloudFormation stack and optionally including a state that sends messages to Amazon SQS. Definitions are built as Python dicts and must be transformed to JSON format before they are used in Step Functions.
stepfunctions_statemachine.py
Shows how to use AWS Step Functions state machine APIs.
stepfunctions_demo.py
Shows how to create a Step Functions state machine that continuously reads message records from an Amazon DynamoDB database and sends them to an Amazon Simple Queue Service (Amazon SQS) queue.
setup.yaml
Contains a CloudFormation script that is used to create the resources needed for
the demo. Pass the deploy or destroy flag to the stepfunctions_demo.py script to
create or remove these resources:
The setup.yaml file was built from the
AWS Cloud Development Kit (AWS CDK)
source script here:
/resources/cdk/python_example_code_stepfunctions_demo/setup.ts.
The unit tests in this module use the botocore Stubber. This captures requests before they are sent to AWS, and returns a mocked response. To run all of the tests, run the following in your [GitHub root]/python/example_code/stepfunctions folder.
python -m pytest
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0