In step function, how do I convert single-object output to array containing single-object.

0

I have a step function with a Map state. The Map state processes an items array which is the output of the task preceding the Map state. Sometimes the task preceding the Map state outputs an array of objects and everything works perfectly. Other times the task preceding the Map state outputs a single object (and not array) so the Map state cannot process it. How do I specify an OutputPath for the task preceding Map state which always returns an array of the tasks output even if the array consists of only a single object?

{
  "Comment": "A description of my state machine",
  "StartAt": "Lambda Invoke",
  "States": {
    "Lambda Invoke": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "Payload.$": "$",
        "FunctionName": "arn:aws:lambda:someregion:someuser:function:somefunctionname:$LATEST"
      },
      "Next": "Map"
    },
    "Map": {
      "Type": "Map",
      "End": true,
      "Iterator": {
        "StartAt": "Success",
        "States": {
          "Success": {
            "Type": "Succeed"
          }
        }
      }
    }
  }
}
已提问 2 年前2702 查看次数
1 回答
0
profile pictureAWS
专家
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则