A Choice state adds conditional logic to a ZIS flow.

"PickChoice": {  "Type": "Choice",  "Choices": [    {      "Variable": "$.input.value",      "StringEquals": "Choice A",      "Next": "NextStateA"    },    {      "Variable": "$.input.value",      "StringEquals": "Choice B",      "Next": "NextStateB"    }  ],  "Default": "NextStateC"}

Supported properties

In addition to common state properties, a Choice state supports the following properties.

NameTypeMandatoryDescription
ChoicesarraytrueArray of choice rule objects. These rules determine the next state in the ZIS flow. Must contain at least one choice rule object
DefaultstringfalseNext state to run if no choice rules in Choices are true

Choice rules

A choice rule object contains a boolean expression. The expression is a comparison that evaluates to true or false. When run, the Choice state evaluates each rule in the Choices array in the order provided. The ZIS flow runs the Next state of the first rule that evaluates to true. If no rule in the Choices array is true, the flow runs the Default state.

A choice rule object requires the following properties:

The object also supports an optional logical operator.

Comparisons

To evaluate a rule, a Choice state compares the input Variable to the value of the comparison operator. For example, the following state compares $.ticket.priority to a static StringEquals value.

"Choice.CheckTicketPriority": {  "Type": "Choice",  "Choices": [    {      "Variable": "$.ticket.priority",      "StringEquals": "Urgent",      "Next": "EscalateTicketStep"    }  ],  "Default": "NormalTicketStep"}

To compare the input variable to a reference path, append Path to the StringEquals key.

Note: Some comparison operators don't support a Path suffix. See comparison operators.

"Choice.CheckTicketPriority": {  "Type": "Choice",  "Choices": [    {      "Variable": "$.ticket.priority",      "StringEqualsPath": "$.settings.ticket_priority",      "Next": "EscalateTicketStep"    }  ],  "Default": "NormalTicketStep"}

Comparison operators

A Choice state supports the following comparison operators.

Comparison operatorPath comparison operator
StringEqualsStringEqualsPath
StringLessThan
StringGreaterThan
StringLessThanEquals
StringGreaterThanEquals
NumericEqualsNumericEqualsPath
NumericLessThanNumericLessThanPath
NumericGreaterThanNumericGreaterThanPath
NumericLessThanEqualsNumericLessThanEqualsPath
NumericGreaterThanEqualsNumericGreaterThanEqualsPath
BooleanEqualsBooleanEqualsPath
TimestampEquals
TimestampLessThan
TimestampGreaterThan
TimestampLessThanEquals
TimestampGreaterThanEquals
IsPresent
IsNull

Logical operators

Use logical operators to combine or negate choice rules in a choice rule object. A Choice state supports the following logical operators:

  • Not
  • And
  • Or

Not example:

"Choice.TicketNotClosed": {  "Type": "Choice",  "Choices": [    {      "Not": {        "Variable": "$.jq_result",        "StringEquals": "Closed"      },      "Next": "ActiveTicketStep"    }  ],  "Default": "ClosedTicketStep"}

And example:

"Choice.WaitingUrgentTicket": {  "Type": "Choice",  "Choices": [    {      "And": [        {          "Variable": "$.ticket.status",          "StringEquals": "New"        },        {          "Variable": "$.ticket.priority",          "StringEquals": "Urgent"        }      ],      "Next": "EscalateTicketStep"    }  ],  "Default": "NormalTicketStep"}

Or example:

"Choice.TicketTopPriorities": {  "Type": "Choice",  "Choices": [    {      "Or": [        {          "Variable": "$.ticket.priority",          "StringEquals": "High"        },        {          "Variable": "$.ticket.priority",          "StringEquals": "Urgent"        }      ],      "Next": "EscalateTicketStep"    }  ],  "Default": "NormalTicketStep"}

Example

For an example of a Choice state in a ZIS flow, see Using conditional branching in a ZIS flow.

Limitations

A ZIS Choice state doesn't support all comparison operators from the Amazon State Language. For supported operators, see Comparison operators.