3

I have a map state that takes an array as input. I understand that the map will iterate over the elements of the array. However, what I want to do is pass the output of one iteration into the input of the next. Is this possible without writing to a DB or S3? I have tried endless combinations of InputPath, OutputPath, and ResultPath, but no matter what I do to try to modify the input of state 1 from state 0, it simply reads from the array, and it seems I can't modify the input array from within the map. Example template:

"Map":{
  "Type": "Map",
  "ItemsPath": "$.stages",
  "Parameters": {
    "stage.$": "$$.Map.Item",
  },
  "Iterator": {
    "StartAt": "StartStage",
    "States": {
      "StartStage":{
        "Type": "Task",
        "Resource":"arn:aws:states:::lambda:invoke.waitForTaskToken",
        "Parameters":{
          "FunctionName":"...",
          "Payload":{
            "myArgs.$": "$.stage.Value",
          }
        },
        "End": true
      }
    }
  },
  "MaxConcurrency": 1,
}
1
  • can you add a sample input to the step function? Commented Feb 24, 2021 at 12:26

1 Answer 1

1

The other option is to create a while loop like this:

  1. Set a variable to track your index (pos = 0)
  2. All the states that you want to iterate
  3. Increase your index ( pos++)
  4. A choice state: If your index is less that your items count go to step1.

This way you have access to the result of previous iteration. But processing and merging the result of iteration is not happening automatically and you need to add a state to do it for you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.