Skip to main content

AWS Step Functions State Machine builder.

The primary motivation for this was the amount of boilerplate (Next, End) required to compose a valid state machine definition, but soon one got carried away.

Python 3.6+ only.

Installation

pip install aws-sfn-builder

Generate State Machine Definition from Simple Description

from aws_sfn_builder import Machine

Machine.parse([
    "a",
    [
        ["b-10", "b-11"],
        ["b-20"],
    ],
    "c",
]).to_json()

This will generate:

{
    "StartAt": "a",
    "States": {
        "a": {
            "Type": "Task",
            "Next": "d3d52323-137d-4228-9956-d3b77cc43a92"
        },
        "d3d52323-137d-4228-9956-d3b77cc43a92": {
            "Type": "Parallel",
            "Next": "c",
            "Branches": [
                {
                    "StartAt": "b-10",
                    "States": {
                        "b-10": {
                            "Type": "Task",
                            "Next": "b-11"
                        },
                        "b-11": {
                            "Type": "Task",
                            "End": true
                        }
                    }
                },
                {
                    "StartAt": "b-20",
                    "States": {
                        "b-20": {
                            "Type": "Task",
                            "End": true
                        }
                    }
                }
            ]
        },
        "c": {
            "Type": "Task",
            "End": true
        }
    }
}

Parse Existing State Machine Definition

# TODO load state_machine_json_dict

state_machine = Machine.parse(state_machine_json_dict)

Compile State Machine

# TODO initialise state_machine

state_machine.compile()

Test Your State Machine

Work in progress.

# TODO initialise state_machine

runner = Runner()

@runner.resource_provider("arn:aws:lambda:us-east-1:123456789012:function:Foo")
def foo(input):
    return "foo-result"

final_state, output = runner.run(state_machine)

Metadata

Release files for aws-sfn-builder 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-sfn-builder 0.0.10
File Size Uploaded
aws-sfn-builder-0.0.10.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-sfn-builder 0.0.10
File Interpreter ABI Platform
aws_sfn_builder-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / aws-sfn-builder-0.0.10.tar.gz

Download URL aws-sfn-builder-0.0.10.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2a05eac6df8d7eb354cf3a0fb431ee4d7fccd117ea39a0dfc90873c3c70064c7
BLAKE2b-256 checksum
How to use checksums
00c5ab655045ecb3665b47dac0b6a728ddd34196debc3dafef8f35ce9fd7f102
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

Release files / aws_sfn_builder-0.0.10-py3-none-any.whl

Download URL aws_sfn_builder-0.0.10-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7201dc9f4e0e6b87c96c8b38d0adce2ee394ce4ce2a02f731a847855f994ddd
BLAKE2b-256 checksum
How to use checksums
9249a0854544c6eed2dc4f265885db94508f554bd2a0c8706ab6aa01b85b6386
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page