I have a simple AWS state machine with two task states that execute C# lambda functions, and one pass state error handler to handle "States.ALL":
{
"Comment": "StateMachine1",
"StartAt": "step1",
"States": {
"step1": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:0000:function:step1",
"Catch": [ {
"ErrorEquals": ["States.ALL"],
"Next": "CatchAllFallback"
} ],
"Next": "step2"
},
"step2": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:0000:function:step2",
"Catch": [ {
"ErrorEquals": ["States.ALL"],
"Next": "CatchAllFallback"
} ],
"End": true
},
"CatchAllFallback": {
"Type": "Pass",
"Result": "This is a fallback from any error code",
"End": true
}
}
}
When one of the steps fails, I get the following as the input to my "CatchAllFallback":
"Error": "Lambda.Unknown",
"Cause": "The cause could not be determined because Lambda did not return an error type."
When I review the Cloudwatch logs, I see that the step timed out. My question is: how do I get that information in my error handler instead of just "Lambda.Unknown"? I know it must be possible, but after spending hours searching the web, I can NOT figure out how to do it. Any advice would be appreciated.
I don't think so that this is supported by default (But maybe someone can proof me wrong?). It's because of the root of the issue. AWS Step Functions expect a valid error type to pass this to the next state but your Lambda timed out and therefore it's impossible to pass a valid error type.
But! You could build a workaround inside your Lambda(s).
Just check the RemainingTime inside the Context Object
and as soon as it is close to get timed out you throw an exception which then can be mapped to a valid error type.
Information about the remaining time of function execution can be used to specify function behavior when nearing the timeout