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 年前檢視次數 2700 次
1 個回答
0
profile pictureAWS
專家
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南