ChoiceTransitionOptions

class aws_cdk.aws_stepfunctions.ChoiceTransitionOptions(*, assign=None, comment=None, outputs=None)

Bases: AssignableStateOptions

Options for Choice Transition.

Parameters:
  • assign (Optional[Mapping[str, Any]]) – Workflow variables to store in this step. Using workflow variables, you can store data in a step and retrieve that data in future steps. Default: - Not assign variables

  • comment (Optional[str]) – An optional description for the choice transition. Default: No comment

  • outputs (Any) – This option for JSONata only. When you use JSONPath, then the state ignores this property. Used to specify and transform output from the state. When specified, the value overrides the state output default. The output field accepts any JSON value (object, array, string, number, boolean, null). Any string value, including those inside objects or arrays, will be evaluated as JSONata if surrounded by {% %} characters. Output also accepts a JSONata expression directly. Default: - $states.result or $states.errorOutput

ExampleMetadata:

infused

Example:

import aws_cdk.aws_events as events
# connection: events.Connection


get_issue = tasks.HttpInvoke.jsonata(self, "Get Issue",
    connection=connection,
    api_root="{% 'https://' & $states.input.hostname %}",
    api_endpoint=sfn.TaskInput.from_text("{% 'issues/' & $states.input.issue.id %}"),
    method=sfn.TaskInput.from_text("GET"),
    # Parse the API call result to object and set to the variables
    assign={
        "hostname": "{% $states.input.hostname %}",
        "issue": "{% $parse($states.result.ResponseBody) %}"
    }
)

update_labels = tasks.HttpInvoke.jsonata(self, "Update Issue Labels",
    connection=connection,
    api_root="{% 'https://' & $states.input.hostname %}",
    api_endpoint=sfn.TaskInput.from_text("{% 'issues/' & $states.input.issue.id & 'labels' %}"),
    method=sfn.TaskInput.from_text("POST"),
    body=sfn.TaskInput.from_object({
        "labels": "{% [$type, $component] %}"
    })
)
not_match_title_template = sfn.Pass.jsonata(self, "Not Match Title Template")

definition = get_issue.next(sfn.Choice.jsonata(self, "Match Title Template?").when(sfn.Condition.jsonata("{% $contains($issue.title, /(feat)|(fix)|(chore)(w*):.*/) %}"), update_labels,
    assign={
        "type": "{% $match($states.input.title, /(w*)((.*))/).groups[0] %}",
        "component": "{% $match($states.input.title, /(w*)((.*))/).groups[1] %}"
    }
).otherwise(not_match_title_template))

sfn.StateMachine(self, "StateMachine",
    definition_body=sfn.DefinitionBody.from_chainable(definition),
    timeout=Duration.minutes(5),
    comment="automate issue labeling state machine"
)

Attributes

assign

Workflow variables to store in this step.

Using workflow variables, you can store data in a step and retrieve that data in future steps.

Default:
  • Not assign variables

See:

https://docs.aws.amazon.com/step-functions/latest/dg/workflow-variables.html

comment

An optional description for the choice transition.

Default:

No comment

outputs

This option for JSONata only.

When you use JSONPath, then the state ignores this property. Used to specify and transform output from the state. When specified, the value overrides the state output default. The output field accepts any JSON value (object, array, string, number, boolean, null). Any string value, including those inside objects or arrays, will be evaluated as JSONata if surrounded by {% %} characters. Output also accepts a JSONata expression directly.

Default:
  • $states.result or $states.errorOutput

See:

https://docs.aws.amazon.com/step-functions/latest/dg/concepts-input-output-filtering.html