amazon-web-servicesaws-step-functions

How to use jsonPath inside array in AWS Step Functions


I am writing an AWS step function, and for one of the steps, I wish to call a lambda that accepts an array as one of the inputs. However, if I try to pass in a JsonPath into the array, I get

The value for the field 'arrayField.$' must be a STRING that contains a JSONPath but was an ARRAY

My step function definition:

{
  "StartAt": "First",
  "States": {
    "First": {
      "Type": "Pass",
      "Parameters": {
        "type": "person"
      },
      "ResultPath": "$.output",
      "Next": "Second"
    },
    "Second": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:us-east-1:<aws_id>:function:MyFunction",
      "Parameters": {
        "regularParameter": "some string",
        "arrayParameter.$": ["$.output.type"]
      },
      "Next": "Succeed"
    },
    "Succeed": {
      "Type": "Succeed"
    }
  }
}

How can I use jsonPath inside the array?


Solution

  • Since a new release you could use the intrinsic function States.Array:

      "arrayParameter.$": "States.Array($.output.type)"
    

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