- Newest
- Most votes
- Most comments
When using the waitForTaskToken pattern with Lambda in Step Functions, the task result structure differs from a standard Lambda invocation.
With waitForTaskToken, the Lambda function initially returns, but the task doesn't complete until an external process calls the Step Functions API with the task token. When this happens, the response from the SendTaskSuccess API call (not the original Lambda return value) becomes the task result.
In your case, when the external service calls SendTaskSuccess, it should include the myLambdaResult value in the payload it sends. The task output will contain only what is passed in the output parameter of the SendTaskSuccess API call.
To make this work, your external process needs to include the Lambda's original output when it calls SendTaskSuccess. For example, if your Lambda returns { "myLambdaResult": "some value" }, your external process should call SendTaskSuccess with this same structure in the output parameter.
Then in your state machine, you can access it directly:
"Assign": { "myLambdaResult": "{% $states.result.myLambdaResult %}" }
The key point is that with waitForTaskToken, the final task output is determined by what's passed to SendTaskSuccess, not by the initial Lambda return value.
Sources
Invoke an AWS Lambda function with Step Functions - AWS Step Functions
Discovering workflow states to use in Step Functions - AWS Step Functions
Relevant content
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
