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"
          }
        }
      }
    }
  }
}
posta 2 anni fa2701 visualizzazioni
1 Risposta
0
profile pictureAWS
ESPERTO
con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande