Number messageAttribute delivered as String in Lambda subscriber to SNS Topic

0

I have 2 listeners on a SNS Topic, a JSON-email and Lambda. When i send a message with MessageAttributes of type Number, I do get them als Numbers in my JSON-email, but as strings in my Lambda event. The same message, with the same messageId looks like this:

  "MessageAttributes" : {
    "Active" : {"Type":"Number","Value":"0"}
  }

and

  "MessageAttributes" : {
    "Active" : {"Type":"String","Value":"0"}
  }

Is this a bug, or am I doing something wrong?

2 Risposte
1
Risposta accettata

SNS messageAttributes of type Number is sent to lambda event as type String. But this is a not a bug as per AWS documentation. https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html

Number data type isn't supported for AWS Lambda subscriptions. If you specify this data type for Lambda endpoints, it's passed as the String data type in the JSON payload that Amazon SNS delivers to Lambda.

prabu
con risposta 2 anni fa
0

Right, I missed that. I can't really understand why that would not be support on Lamda's though. It would still be the same StringValue, only the Type would be differently named.

CP_2022
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