Is there a way to create a Choice rule in StepFunction to determine if an array field has any elements?
Current StepFunction documentation doesn't list any collection-specific comparison operators so I'm wondering if it's possible to achieve this without implementing a separate lambda to test if an array is empty?
Adding to @cclusetti 's answer, you can use IsPresent
to check whether the first element of your array exists. If it is present, the array is not empty. If it is not present, then either the array is empty or missing.
"Choices":[
{
"Variable":"$.myArray[0]",
"IsPresent":true,
"Next":"NotEmpty"
}
]
No, you cannot check array field in Choice
state. Only way is to set it in the input received from the preceding state.
"Choices":[
{
"Variable":"$.isEmpty",
"BooleanEquals":true,
"Next":"NextState"
}
]
As of Aug 2020, post release, aws has added isPresent
and to Choice
states. An option here is that if your array is empty then either don't set the key or set it to null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With