Parse SNS for AWS Lambda Object

Worked with the recently released SDK, which supports C # lambdas. I have an SNS theme setting published by Lambda A. Everything is working fine. Now I have Lambda B, which is subscribed to the same topic. When I start Lambda Lambda B and the JSON message is sent. The problem is that I cannot get JSON to parse the Amazon.SimpleNotificationService.Util.Message type.

I gave this JSON.

{
"Records": [
{
  "EventSource": "aws:sns",
  "EventVersion": "1.0",
  "EventSubscriptionArn": "arn:.......",
  "Sns": {
    "Type": "Notification",
    "MessageId": "ce4a1d7c-c50d-51ea-bfe8-4dc1078795fe",
    "TopicArn": "arn:.......",
    "Subject": null,
    "Message": "test queue",
    "Timestamp": "2016-12-04T07:05:46.709Z",
    "SignatureVersion": "1",
    "Signature": "<mysighere>",
    "SigningCertUrl": "<pem url here>",
    "UnsubscribeUrl": "<unsub url here>",
    "MessageAttributes": {}
   }
  }
 ]
}

So, I tried to make this code (where messageText is of type "object", which gives me only the "Sns" node.

var j = Newtonsoft.Json.Linq.JObject.Parse(messageText.ToString());
var sns = jsonData["Records"][0]["Sns"];

Console.Write($"sns object: {sns}");
var message = Message.ParseMessage(sns.ToString());

But calling ParseMessage raises an error indicating that the SigningCertUrl field is null. I wrote JSON in cloudwatch and I see that all fields are filled.

? , Lambda serializer Message , , null.

+4
1

, AWS SDK . parseMessage ( , , ). , "URL" ( ) "Url"

  message.SigningCertURL = Message.ValidateCertUrl(func("SigningCertURL"));
  message.SubscribeURL = func("SubscribeURL");
  message.UnsubscribeURL = func("UnsubscribeURL");

JSON

"SigningCertUrl": "<pem url here>",
"UnsubscribeUrl": "<unsub url here>",

, , , null. - ValidateCertUrl .

, JSON, "URL" "Url", .

GitHub . https://github.com/aws/aws-sdk-net/issues/502

UPDATE GitHub, , , . , :(

. Amazon.Lambda.SNSEvents

+2

Source: https://habr.com/ru/post/1662756/


All Articles