Having worked with AWS step functions for a little while now, i’ve had to jump a few hurdles to get what I wanted, and I figured other people could benefit from the hours of hair pulling. Sharing is caring, or so they say…
Lifting a parameter into an array
Occasionally you’ll want to convert a value to an array of that value. This can often be the case if you want to map over a single value or use a dynamic parameter with an ECS task invocation as a Command
argument (because it only accepts arrays, not a string 🤷♂).
Interestingly the Pass
type allows you to perform some interesting parameter movements. Both InputPath
and ResultPath
are valid (and the sneaky Parameters
option is also available if you want create bigger objects)
{
"StartAt": "Lift to Array",
"States": {
"Lift to Array": {
"Type": "Pass",
"InputPath": "$.param",
"ResultPath": "$.paramList[0]",
"Next": "Replace"
},
"Replace": {
"Type": "Pass",
"InputPath": "$.paramList",
"ResultPath": "$.param",
"End": true
}
}
}
As you can see from the above, we lift the $.param
into $.paramList[0]
i.e. position 0 of an array, then we just replace the $.param
in the subsequent step - $.param
is now an array.
#big-data #analytics #aws-step-functions #aws #workflow