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?

CP_2022
已提問 2 年前檢視次數 868 次
2 個答案
1
已接受的答案

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
已回答 2 年前
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
已回答 2 年前

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

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

回答問題指南