Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

amazon web services - Step Functions - Use output from older step in later step (non-sequential)

In a state machine with 3 steps, is it possible for step 3 to use the output of step 1? In my specific scenario I have:

Task -> Map State -> Task

where I'm specifically interested in using the Map State's input for its first iteration as the input for Step 3. I could handle the entire input to the map state as well, but so far I'm not seeing how to achieve either of these.

question from:https://stackoverflow.com/questions/65830196/step-functions-use-output-from-older-step-in-later-step-non-sequential

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

"ResultPath":"$.mapOutput" will prefix mapOutput to output of the map. and combined input and output will be send as input to following task.

This is input to Step 3:

{
  "Comment": "Insert your JSON here",
  "inputForMap": [
    "iter 1",
    "iter2"
  ],
  "mapOutput": [
    "iter 1",
    "iter2"
  ]
}

Here is entire definition

{
   "StartAt":"Dummy Step 1 Output",
   "States":{
      "Dummy Step 1 Output":{
         "Type":"Pass",
         "Result":[
            "iter 1",
            "iter2"
         ],
         "ResultPath":"$.inputForMap",
         "Next":"loop on map"
      },
      "loop on map":{
         "Type":"Map",
         "ResultPath":"$.mapOutput",
         "Next":"Step three",
         "Iterator":{
            "StartAt":"Step 2 - Looping on map",
            "States":{
               "Step 2 - Looping on map":{
                  "Type":"Pass",
                  "End":true
               }
            }
         },
         "ItemsPath":"$.inputForMap",
         "MaxConcurrency":1
      },
      "Step three":{
         "Type":"Pass",
         "Next":"End of Step Function"
      },
      "End of Step Function":{
         "Type":"Pass",
         "End":true
      }
   }
}

enter image description here

Step three Input: enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...