Пример #1
0
def build() -> StateMachine:
    workflow = StateMachine(
        Comment=
        "This is a simple state machine with a single choice and three end states."
    )

    decision = workflow.start_with(Choice("TheBeginning"))

    decision.if_(VariablePath("$.value") == "A").then(
        Task("ResultA",
             Resource="arn:aws:lambda:us-east-1:123456789012:function:A")).end(
             )

    decision.if_(VariablePath("$.value") == "B").then(
        Task("ResultB1",
             Resource="arn:aws:lambda:us-east-1:123456789012:function:B1")
    ).then(
        Task("ResultB2",
             Resource="arn:aws:lambda:us-east-1:123456789012:function:B2")
    ).end()

    decision.else_(
        Fail("Unknown", Error="Unhandled Case", Cause="Unknown Value"))

    return workflow
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
Пример #3
0
def test_promote(path_reader, source_result, requested_promotion,
                 expected_input):
    machine = StateMachine()
    starter = machine.start_with(
        Pass("Foo", ResultPath=JsonPath(source_result)))
    test = starter.promote(path_reader(requested_promotion))

    assert test.title == "Foo-PromoteResult"
    assert test.InputPath == JsonPath(expected_input)
    assert test.ResultPath == JsonPath(source_result)
    assert test.member_of is machine
Пример #4
0
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
Пример #5
0
def build() -> StateMachine:
    workflow = StateMachine(Comment="This is a state machine with three simple tasks.")

    workflow.start_with(
        Task("TaskOne", Resource="arn:aws:lambda:us-east-1:123456789012:function:One")
    ).then(
        Task("TaskTwo", Resource="arn:aws:lambda:us-east-1:123456789012:function:Two")
    ).then(
        Task(
            "TaskThree", Resource="arn:aws:lambda:us-east-1:123456789012:function:Three"
        )
    ).end()

    return workflow
Пример #6
0
def build() -> StateMachine:
    lookup_address = StateMachine()
    lookup_address.start_with(
        Task(
            "LookupAddress",
            Resource=
            "arn:aws:lambda:us-east-1:123456789012:function:AddressFinder",
        )).end()

    lookup_phone = StateMachine()
    lookup_phone.start_with(
        Task(
            "LookupPhone",
            Resource=
            "arn:aws:lambda:us-east-1:123456789012:function:PhoneFinder",
        )).end()

    parallel_run = Parallel("LookupCustomerInfo")
    parallel_run.add_branch(lookup_address)
    parallel_run.add_branch(lookup_phone)

    workflow = StateMachine(Comment="Parallel Example.")
    workflow.start_with(parallel_run).end()

    return workflow
Пример #7
0
def build_and_try_single_step_state_machine(step):
    workflow = StateMachine()
    workflow.start_with(step).end()

    definition = json.dumps(workflow.to_dict())
    try_to_create_and_delete_state_machine(definition)