in AWS step functions I know we can use resultPath
to pass the current state's output to the next state along in its inputs. Say I have 3 states A, B, and C, when A finishes executing it passes its input and output to B as input, when B finishes, is there a way to pass B's output along with A's output input to C as inputs? Please advise, thanks!
CodePudding user response:
if you only have a resultPath
on your task then it appends the result to the incoming event of that task - So if Task A takes an Input of
{
TaskAInput: Stuff
}
And has only a resultPath: TaskAOutput
then the input for task B will be:
{
TaskAInput: Stuff
TaskAOutput: TaskAResult
}
That enters into Task B. If Task B only has a resultPath: TaskBOutput
then
{
TaskAInput: Stuff
TaskAOutput: TaskAResult
TaskBOutput: TaskBesult
}
and so on down the chain.
Note. If you attach an outputPath
to any of the above steps it will output only that json path from the final combined input and results. If you use an inputPath at all it will cut down the input to just that going forward.
CodePudding user response:
You just have to do the following:
A function:
def lambda_handler(event, context):
...
result = ...
return {
"Ainput":event,
"Aoutput": result
}
B function:
def lambda_handler(event, context):
...
result = ...
return {
"Ainput": event['Ainput'],
"Aoutput": event['Aoutput'],
"Boutput": result
}
C function:
def lambda_handler(event, context):
Ainput = event['Ainput']
Aoutput = event['Aoutput']
Boutput = event['Boutput']
Now you can use that results on your C function as you want.