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

Stepfunction map with condition


Is there is any possibility to run the was step function map Iterator based on the condition Am going to invoke the lambda and based on the result I have to choose the input item of the iteration meaning if there is an array of 0-3 items once the first item executes with lambda then based on the result it should execute 1st index or 2nd index item.


Solution

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

    • Set a variable to track your index (pos = 0)
    • Do whatever you want to do inside your iteration also you could use some condition, if you want to process each item conditionally
    • increase your index ( pos++)
    • If your index is less that your items count go to step1.

    This way you have access to the result of previous iteration, so you can fine tune your condition.