Have been working with the recently released SDK that has support for C# lambdas. I have an SNS topic setup that Lambda A publishes to. That all is working fine. Now I have Lambda B that is subscribed to that same topic. When I fire of Lambda A Lambda B is triggered and a JSON message is passed. The issue is I can't seem to get the JSON parsed to the Amazon.SimpleNotificationService.Util.Message type.
I have given 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 have tried to do this code (where messageText is of type "object" parameter which does give me just 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 the ParseMessage calls throws an error saying the SigningCertUrl field is null. I have written the JSON out to cloudwatch and I see all the fields are populated.
Where am I off track here? I thought the Lambda serializer might just parse the Message parameter for me but when I tried that all the properties where null.
Console.Write($"sns object: {sns}");?