Search code examples
amazon-web-servicesaws-lambdaaws-step-functions

Using Map type to start an execution of state machine


I am trying to using the AWS step function map type to start a execution of a statemachine for each item that is mapped. It's not working and I couldn't find any examples. Is there support for this? If so, can anyone tell me what I'm doing wrong here.

  "Batch": {
      "Type": "Map",
      "InputPath": "$.batch",  // this will contain an array of 20 files to be processed
      "MaxConcurrency": 0,
      "Iterator": {
        "StartAt": "BatchProcess",
        "States": {
          "BatchProcess": {
            "Type": "Task",
          "Resource": "arn:aws:states:::states:startExecution.sync:2",
          "Parameters": {
            "Input": {
              "Files.$": "$.batch.Files"
            },
            "StateMachineArn": "my-state-machine-arn"
          },
          "ResultPath": "$.batch",
          "OutputPath": "$.batch.Output",
          "Next": "Done"
          }
        }
      },
      "ResultPath": "$.batch",
  "OutputPath": "$.batch.Output",
      "Next": "next-lambda-function-after-all-files-in-batch-are-processed"
    },

Solution

  • Based on the doc: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-map-state.html

    You should use ItemsPath, not InputPath to point to your array.