Here is my step function:
{
"Comment": "A description of my state machine",
"StartAt": "lambda1",
"States": {
"lambda1": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$"
},
"Next": "lambda2"
},
"lambda2": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": {
"item_id.$": "$.item_id"
}
},
"Next": "lambda3"
},
"lambda3": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": {
"item_id.$": "" <------- How to access the id here
"data.$": $.data
}
},
"End": true
}
}
}
I am passing an item_id to lambda2, and that lambda returns some output data.
In lambda3, I need the output data of lambda2 as well as the item_id that was passed to lambda2 from lambda1.
I cannot modify the application code for lambda2 to also return the item_id passed to it.
Is it possible for me to pass the item_id from lambda1 all the way to lambda3?
Yes, this is possible using
ResultPath.I've detailed the various outcomes of using
ResultPathin my answer here.In your case, you need a
ResultPathof$.DataFromLambda1set forlambda2which would set the state input oflambda3to:lambda1(which is theitem_id)lambda2.Then change
lambda3to: