Reputation: 503
I have a workflow with 3 steps:
What I would like is to only do Step 3 if any iterations occur in Step 2. The way this is designed, Step 1 usually produces no output, so Step 2 is basically skipped.
I've noticed that in the scenario I've outlined, the output from Step 2 is just []
, where as normally it contains a whole lot of information about the iterations. Is it possible to perform this kind of workflow?
Upvotes: 3
Views: 4084
Reputation: 10393
Choice state after step 1 to check if there is at least one record in Map, we can't check length of array, so using isPresent
on first element of map $.inputForMap[0]
Step Definition
{
"StartAt":"Dummy Step 1 Output",
"States":{
"Dummy Step 1 Output":{
"Type":"Pass",
"Result":[
"iter 1",
"iter2"
],
"ResultPath":"$.inputForMap",
"Next":"does map has atleast one record?"
},
"does map has atleast one record?":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.inputForMap[0]",
"IsPresent":true,
"Next":"loop on map"
}
],
"Default":"End of Step Function"
},
"End of Step Function":{
"Type":"Pass",
"End":true
},
"Step three":{
"Type":"Pass",
"Next":"End of Step Function"
},
"loop on map":{
"Type":"Map",
"Next":"Step three",
"Iterator":{
"StartAt":"Step 2 - Looping on map",
"States":{
"Step 2 - Looping on map":{
"Type":"Pass",
"End":true
}
}
},
"ItemsPath":"$.inputForMap",
"MaxConcurrency":1
}
}
}
When Map is not empty
When Map is empty
Upvotes: 4