Hello WorldΒΆ

This example shows a very simple state machine, with a single state that invokes a Lambda Function Task state.

The troposphere version demonstrates how Troposphere objects can be passed as references rather than having to provide a string value.

start
:Hello World;
stop

"""
A simple hello-world workflow with a single Lambda Task state.
"""
from rhodes.states import StateMachine, Task


def build() -> StateMachine:
    workflow = StateMachine(Comment="A simple minimal example of the States language")

    workflow.start_with(
        Task(
            "Hello World",
            Resource="arn:aws:lambda:us-east-1:123456789012:function:HelloWorld",
        )
    ).end()

    return workflow
{
    "Comment": "A simple minimal example of the States language",
    "StartAt": "Hello World",
    "States": {
        "Hello World": {
            "Type": "Task",
            "Resource": "arn:aws:lambda:us-east-1:123456789012:function:HelloWorld",
            "InputPath": "$",
            "OutputPath": "$",
            "ResultPath": "$",
            "End": true
        }
    }
}
"""
A simple hello-world workflow with a single Lambda Task state.
"""
from troposphere import awslambda

from rhodes.states import StateMachine, Task


def build() -> StateMachine:
    lambda_function = awslambda.Function(
        "HelloWorldFunction", Code=awslambda.Code(ZipFile="foo bar")
    )

    workflow = StateMachine(Comment="A simple minimal example of the States language")

    workflow.start_with(Task("Hello World", Resource=lambda_function)).end()

    return workflow
{
    "Comment": "A simple minimal example of the States language",
    "StartAt": "Hello World",
    "States": {
        "Hello World": {
            "Type": "Task",
            "Resource": "${HelloWorldFunction.Arn}",
            "InputPath": "$",
            "OutputPath": "$",
            "ResultPath": "$",
            "End": true
        }
    }
}