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 年前867 查看次数
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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则