Search code examples
aws-lambdaaws-step-functions

Step function dynamic execution


I have two Lambda functions: first one runs and creates a list of specific time to run at for function 2 ex {"2020-09-04T01:59:00Z","2020-09-04T02:59:00Z","2020-09-04T03:59:00Z","2020-09-04T04:59:00Z"}

I have only managed to create it using one input only: ex:

{
    "Comment": "Fixtures Wait state",
    "StartAt": "FirstState",
    "States": {
        "FirstState": {
            "Type": "Task",
            "Resource": "arn:aws:lambda:${aws_region}:${aws_account_id}:function:hello",
            "ResultPath": "$.first",
            "Next": "wait_using_timestamp_path"
        },
        "wait_using_timestamp_path": {
            "Type": "Wait",
            "TimestampPath": "$.expirydate",
            "Next": "wait_using_seconds_path"
        },
        "FinalState": {
            "Type": "Task",
            "Resource": "arn:aws:lambda:${aws_region}:${aws_account_id}:function:hello",
            "End": true
        }
    }
}

is it possible to have it process all inputs? or am i thinking wrong?


Solution

  • The Map state can be used to execute an iterator over an array of inputs. After the first Lambda Task, put the steps you want to execute for each item in the output array in a Map state.

    https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-map-state.html