I want to branch the flow of an AWS State Machine based on how many items are in an array. If the array has 0 items, I want to end the flow. If it has more than 0 items, I want to do some stuff.
For example, I want to do something like the following:
{
"StartAt": "IsBig",
"States": {
"IsBig": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.things.length",
"NumericGreaterThan": 0,
"Next": "Big"
}
],
"Default": "Small"
},
"Big": {
"Type": "Pass",
"Result": "1",
"End": true
},
"Small": {
"Type": "Pass",
"Result": "0",
"End": true
}
}
}
I'd then pass in the following on execution:
{ "things": [1, 2, 3] }
I'd want IsBig
to then call Big
and end.
Is there a way to do that in AWS states language?
If I can't, I'll just create a Lambda that gets the array's length. I am just curious.
The answer is "no". You can't run a function from the "Variable": "$.things.length"
property.
The value in the Variable
field is a.... variable. It's not an expression.
The docs don't show any expression evaluation syntax. So, long story short, you can't do what I was looking to do.