amazon-web-servicesaws-cdkaws-step-functionsaws-cdk-typescriptaws-cdk-context

How to catch error in AWS distributed map state


I'm facing some issues with StepFunctions... Is there a way to Catch errors like States.ExceedToleratedFailureThreshold in DistributedMaps? I have something like this but somehow the Catch isn't applied and the execution just fails when at least one Lambda is failing:

{
  "Next": "ReleaseSlot",
  "Type": "Map",
  "ItemReader": {
    "ReaderConfig": {
      "InputType": "CSV",
      "CSVHeaderLocation": "FIRST_ROW"
    },
    "Resource": "arn:aws:states:::s3:getObject",
    "Parameters": {
      "Bucket": "<BUCKET>",
      "Key.$": "$.filename"
    }
  },
  "ItemBatcher": {
    "MaxItemsPerBatch": 1000,
    "BatchInput": {
      "data.$": "$"
    }
  },
  "ItemProcessor": {
    "StartAt": "BatchImporter",
    "States": {
      "BatchImporter": {
        "Type": "Task",
        "Resource": "arn:aws:states:::lambda:invoke",
        "Parameters": {
          "FunctionName": "<FUNCTION_ARN>",
          "Payload": {
            "body": "$"
          }
        },
        "ResultPath": null,
        "OutputPath": null,
        "End": true
      }
    },
    "ProcessorConfig": {
      "Mode": "DISTRIBUTED",
      "ExecutionType": "STANDARD"
    }
  },
  "MaxConcurrency": 16,
  "ToleratedFailurePercentage": 0,
  "Catch": [
    {
      "ErrorEquals": [
        "States.All"
      ],
      "Next": "ReleaseSlot"
    }
  ]
}

I wanted to catch this error, as if it occurred then distributed map failed to run "ReleaseSlot" state, which leads to inconsistent state.


Solution

  • The casing in your Error name is incorrect. You need to use States.ALL (capitalized ALL).