Reputation: 15019
I'm attempting to create an AWS step function with a Map
state whose input (that is, the array to iterate over) comes from the Execution Input. A reduce example JSON step function looks like:
{
"StartAt": "pass",
"States": {
"pass": {
"Type": "Pass",
"Next": "map-sleep"
},
"map-sleep": {
"MaxConcurrency": 5,
"InputPath": "$$.Execution.Input['data']",
"Iterator": {
"StartAt": "wait",
"States": {
"wait": {
"SecondsPath": "$['length']",
"Type": "Wait",
"End": true
}
}
},
"Type": "Map",
"Next": "final-wait"
},
"final-wait": {
"Seconds": 10,
"Type": "Wait",
"End": true
}
}
}
However, when I attempt to create this, I'm greeted by the error:
An error occurred (InvalidDefinition) when calling the CreateStateMachine operation: Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: Value must be a valid JSONPath. at /States/map-sleep/InputPath'
I infer from this that the InputPath
is wrong, but I don't quite understand why, or what the correct way to express what I'm trying to do is. (This code was generated using the Python Step Functions SDK, and if it's helpful I can share this code, but I figured reducing it to the JSON would make it easier to consider).
Upvotes: 1
Views: 1331
Reputation: 15019
Well, I strongly suspect this is not the optimal answer, but it looks like by combining a Pass
node using Parameters
with a Map
node, you can get the desired outcome:
"map-sleep-pass": {
"Parameters": {
"items.$": "$$.Execution.Input['data']"
},
"Type": "Pass",
"Next": "map-sleep"
},
"map-sleep": {
"MaxConcurrency": 5,
"InputPath": "$.items",
"Iterator": {
"StartAt": "wait",
"States": {
"wait": {
"SecondsPath": "$['length']",
"Type": "Wait",
"End": true
}
}
},
"Type": "Map",
"Next": "final-wait"
},
Upvotes: 0