I am using AWS Step Functions with a Map state and I am facing an issue where, when an error occurs in the iterations of the map, the execution continues further, and the result of the map execution ends up being the error States.ExceedToleratedFailureThreshold. I want to terminate the execution of the map on any error and return that error as the map execution result.
Here’s my current configuration for the map:
ProcessDistributed:
Type: Map
Label: "ProcessDistributed"
MaxConcurrency: 1
ToleratedFailureCount: 0
ItemsPath: "$.response"
ResultPath: "$.result"
Parameters:
"item.$": "$$.Map.Item.Value"
"a.$": "$.a"
ItemProcessor:
ProcessorConfig:
Mode: "DISTRIBUTED"
ExecutionType: "STANDARD"
StartAt: ProcessItem
States:
ProcessItem:
Type: Task
Resource:
Fn::GetAtt: [ Activity, Arn ]
Parameters:
"parameter.$": "$.a."
"item.$": "$.item"
ResultPath: "$.response"
Next: Final
TimeoutSeconds: 360
Catch:
- ErrorEquals:
- "States.ALL"
ResultPath: "$.error"
Next: FailProcessingItem
FailProcessingItem:
Type: Fail
Final:
Type: Pass
InputPath: "$.any"
End: true
Catch:
- ErrorEquals:
- "States.DataLimitExceeded"
ResultPath: "$.error"
Next: B_Failure
- ErrorEquals:
- "States.Runtime"
ResultPath: "$.error"
Next: B_Failure
- ErrorEquals:
- "States.ALL"
ResultPath: "$.error"
Next: B_Failure
How can I terminate the execution of the map on any error and return that error as the map execution result? Currently, when an error happens, the result looks like this:
{
"cause": "The specified tolerated failure threshold was exceeded",
"error": "States.ExceedToleratedFailureThreshold"
}