RJK
RJK

Reputation: 242

AWS step functions nested map steps

Is there a solution available currently for using a map step inside another map step in AWS step functions?

I am currently trying to do exactly this, but I am getting the exact error as this question: AWS step functions - Nested Map type

But I haven't been able to find a solution and I've searched everywhere.

Upvotes: 0

Views: 1226

Answers (2)

RobotCharlie
RobotCharlie

Reputation: 1278

Now, you can just:

  1. Edit the step function
  2. Click Workflow Studio
  3. Create any two Map States, and drag one into another like this screenshot screenshot

Upvotes: 0

Pooya Paridel
Pooya Paridel

Reputation: 1401

Yes, you can add nested map inside map and you can repeat this pattern as much as you want. Here is a simple example:

{
  "StartAt": "Data1",
  "States": {
    "Data1": {
      "Type": "Pass",
      "Result": {
        "array1": [0,1]
      },
      "Next": "Map1"
    },
    "Map1": {
      "Type": "Map",
      "ItemsPath": "$.array1",
      "ResultPath": "$.array1",
      "MaxConcurrency": 2,
      "End": true,
      "Iterator": {
        "StartAt": "Data2",
        "States": {
          "Data2": {
            "Type": "Pass",
            "Result": {
              "array2": [0,1,2]
            },
            "Next": "Map2"
          },
          "Map2": {
            "Type": "Map",
            "ItemsPath": "$.array2",
            "ResultPath": "$.array2",
            "MaxConcurrency": 2,
            "End": true,
            "Iterator": {
              "StartAt": "Wait",
              "States": {
                "Wait": {
                  "Type": "Wait",
                  "Seconds": 1,
                  "End": true
                }
              }
            }
          }
        }
      }
    }
  }
}

To make it simple for you, I hardcoded arrays in Data1 and Data2 steps so you could execute my example without passing any execution input.

enter image description here

Upvotes: 4

Related Questions