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"
          }
        }
      }
    }
  }
}
gefragt vor 2 Jahren2701 Aufrufe
1 Antwort
0
profile pictureAWS
EXPERTE
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen