I am building an API which will be serviced by Lambda functions but I need these to be asynchronous so rather than connecting the API-Gateway directly to the Lambda function
I did eventually get this to work after working with AWS support. Here's my solution:
POST
you will not be able to send a JSON message in the body of the message as you might expectdefault
which in SNS-world means the "default channel"/**
* When this is run in AWS it is run "through" a SNS
* event wconfig.ich adds a lot of clutter to the event data,
* this tests for SNS data and normalizes when necessary
*/
function abstractSNS(e) {
if (e.Records) {
return JSON.parse(decodeURIComponent(e.Records[0].Sns.Message)).default;
} else {
return e;
}
}
/**
* HANDLER
* This is the entry point for the lambda function
*/
exports.handler = function handler(event, context) {
parent.event = abstractSNS(event);