Issue: Can someone please point me in the right direction as to what I am doing incorrectly with my state syntax? My lambda function is unable to read a parallel task output, but succeeds in running. Here's what the output looks like (and step input and state syntax at the very bottom):
"Payload": {
"brand_iteration_list": [],
"user_msg": "It did something!"
}
Context: I am trying to pass the results of a Parallel task into a Lambda function to combine the inputs and generate a new array - which I want to iterate over afterwards. My parallel task consist of 2 lambda functions which:
- returns an array consisting of brand objects
- returns an array of brand properties that each brand needs an iteration for
My lambda function takes the output of the parallel task (an array) and then combines the two, iterating over each brand, then creating an object of each brand with the brand properties, and appending it to a "final array" to be returned at the end via JSON object.
- Note 1: When I take the Step Input and test my lambda function directly, it is outputting as expected.
- Note 2: When that same function runs through the Step Functions, it appears that the output is not being passed. Therefore, that is why I believe my state syntax is incorrectly setup.
State Syntax:
{
"Comment": "Generate Token",
"StartAt": "Get_Token",
"States": {
"Get_Token": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "arn:aws:lambda..."
},
"Next": "Get_Brand_List_and_Brand_Props"
},
"Get_Brand_List_and_Brand_Props": {
"Type": "Parallel",
"Next": "Create_Brand_Iteration_Array",
"InputPath": "$.Payload",
"Parameters": {
"Input.$": "$"
},
"Branches": [
{
"StartAt": "Get_Brand_List",
"States": {
"Get_Brand_List": {
"Type": "Task",
"Resource": "arn:aws:lambda...",
"End": true
}
}
},
{
"StartAt": "Get_Brand_Props",
"States": {
"Get_Brand_Props": {
"Type": "Task",
"Resource": "arn:aws:lambda...",
"End": true
}
}
}
]
},
"Create_Brand_Iteration_Array": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"InputPath": "$",
"Parameters": {
"FunctionName": "arn:aws:lambda..."
},
"Next": "Retrieve_Brand_Info"
},
"Retrieve_Brand_Info": {
"Type": "Pass",
"End": true
}
}
}
Step Input going into Lambda that returns empty array []:
[
{
"brand_list": [
{
"name": "..."
},
{
"name": "..."
},
{
"name": "..."
},
"user_msg": "Brand list retrieved"
}
},
{
"brand_props: [
{
"prop": "...",
"prop2": "..."
},
{
"prop": "...",
"prop2": "..."
},
{
"prop": "...",
"prop2": "..."
},
"user_msg": "Brand props retrieved"
}
}
]
print(event.get('body'))in your lambda function, does it match the input from as whats the AWS console?"Payload.$": "$", to yourParameters. I typically prefer to use this over the specifying the arn in the resource, since you can dynamically set the function{name,arn,version} etc if needed