Reputation: 672
I am working on a solution where a state functions is suppose to fetch the required functions to be completed(based on input) and then needs to trigger those functions in parallel, so that i have a consolidated output in the end. This can be illustrated as below -
After the requirements based on the input has been fetched, the next state can be any combination of the states below but they do need to run in parallel so that i know all required tasks have been completed. I do not want to keep a bunch of choices or deciders, since the umber of required steps can grow in the future. Is it possible to to decide on which branches are required to be run in parallel and run them.
Upvotes: 2
Views: 2051
Reputation: 10393
we will need a choice within each branch.
{
"StartAt":"Build Decider Step Output",
"States":{
"Build Decider Step Output":{
"Type":"Pass",
"Result":{
"firstReq":true,
"secondReq":true,
"thridReq":false
},
"ResultPath":"$.decider",
"Next":"my-parallel"
},
"my-parallel":{
"Type":"Parallel",
"End":true,
"Branches":[
{
"StartAt":"should we run first step?",
"States":{
"should we run first step?":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.decider.firstReq",
"BooleanEquals":true,
"Next":"First Requirement"
}
],
"Default":"First Req Skipped"
},
"First Req Skipped":{
"Type":"Pass",
"End":true
},
"First Requirement":{
"Type":"Pass",
"End":true
}
}
},
{
"StartAt":"should we run second step?",
"States":{
"should we run second step?":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.decider.secondReq",
"BooleanEquals":true,
"Next":"Second Requirement"
}
],
"Default":"Second Req Skipped"
},
"Second Req Skipped":{
"Type":"Pass",
"End":true
},
"Second Requirement":{
"Type":"Pass",
"End":true
}
}
},
{
"StartAt":"should we run thrid step?",
"States":{
"should we run thrid step?":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.decider.thridReq",
"BooleanEquals":true,
"Next":"Third Requirement"
}
],
"Default":"Third Req Skipped"
},
"Third Req Skipped":{
"Type":"Pass",
"End":true
},
"Third Requirement":{
"Type":"Pass",
"End":true
}
}
}
]
}
}
}
I mocked this json in first step output
{
"firstReq":true,
"secondReq":true,
"thridReq":false
}
and resulted in below, skipping third branch.
Upvotes: 1