I have created a basic state machine that runs a lambda and then uses the output of that lambda to decide a choice. However, I have not been able to receive the output from the lambda function because it keeps returning a null payload. I have tried running the lambda alone from the lambda console and it runs fine (including with the expected return). However, within the step function, the task at least, is returning null for the Payload output.
Here is the definition of my state-machine:
{
"StartAt": "ValidateWorkcellConfigTask",
"States": {
"ValidateWorkcellConfigTask": {
"Next": "ConfigValidationTypeChoiceState",
"Parameters": {
"FunctionName": "ValidateWorkcellConfig",
"InvocationType": "Event",
"Payload.$": "$"
},
"OutputPath": "$",
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"TimeoutSeconds": 15
},
"ConfigValidationTypeChoiceState": {
"Type": "Choice",
"Comment": "Forwards a VALID workflow config to the Provisioning Workflow or Relays the INVALID workflow config for logging",
"Choices": [
{
"Variable": "$.uuid",
"StringEquals": "SEA90-1",
"Next": "endState"
},
{
"Variable": "$.validConfig",
"StringEquals": "SEA90-1",
"Next": "SuccessRelayTask"
}
]
},
"endState": {
"Type": "Pass",
"End": true
},
"SuccessRelayTask": {
"End": true,
"Parameters": {
"FunctionName": "StatusRelayHandler",
"InvocationType": "Event",
"Payload.$": "$"
},
"OutputPath": "$",
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"ResultPath": "$",
"TimeoutSeconds": 15
}
}
}
And here is the output of the lambda task execution:
{
"name": "ValidateWorkcellConfigTask",
"output": {
"Payload": null,
"SdkHttpMetadata": {
"AllHttpHeaders": {
"x-amzn-Remapped-Content-Length": [
"0"
],
"Connection": [
"keep-alive"
],
"x-amzn-RequestId": [
"4452a8d2-e607-4ae6-943c-9478b0f59ce0"
],
"Content-Length": [
"0"
],
"Date": [
"Sat, 16 Jan 2021 09:22:48 GMT"
],
"X-Amzn-Trace-Id": [
"root=1-6002b068-52fb3d1f60f20d3e10804f96;sampled=0"
]
},
"HttpHeaders": {
"Connection": "keep-alive",
"Content-Length": "0",
"Date": "Sat, 16 Jan 2021 09:22:48 GMT",
"x-amzn-Remapped-Content-Length": "0",
"x-amzn-RequestId": "4452a8d2-e607-4ae6-943c-9478b0f59ce0",
"X-Amzn-Trace-Id": "root=1-6002b068-52fb3d1f60f20d3e10804f96;sampled=0"
},
"HttpStatusCode": 202
},
"SdkResponseMetadata": {
"RequestId": "4452a8d2-e607-4ae6-943c-9478b0f59ce0"
},
"StatusCode": 202
},
"outputDetails": {
"truncated": false
}
}
Notice how the payload is null... that is causing the next task to fail because it receives a null input. I've already played around with OutputPath, ResultPath, and InputPath but have never been able to return something from the lambda task.
The lambda itself is written in Java and return a String. It implements this interface:
... implements RequestHandler<WorkcellConfig, String>
"FunctionName": "ValidateWorkcellConfig"- is this also in your real configuration? Because you should define the function ARN here, not just a function name.