'AWS Step Function itemsPath potentially empty

I have a Parallel state with four branches. Each branch is represented by a Map state.

I chunk my array into sub-arrays of 250 items in a lambda, return it, and pass it to itemsPath via Step Function context like:

itemsPath: '$.props0'

There is every chance sometimes one to three of my 4 sub-arrays will be empty, this is causing a number of branches in my SF to fail with below error:

Unable to apply step \"props1\" to input

Is there any way to make itemsPath optional? Or only run a Map state if itemsPath is not empty?



Solution 1:[1]

I accounted for this in my lambda, then leveraged a Condition inside a Choice, and called the appropriate State - either a single Map, or my four nested Maps in my Parallel.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1