What is the callback doing in lambda handler? It seems to be using sns
variable and I intend to modify the variables.
exports.handler = function(event, context, callback) {
console.log("AWS lambda and SNS trigger ");
console.log(event);
const sns = event.Records[0].Sns.Message;
console.log(sns)
callback(null, sns);
};
I'm trying to modify the code to something like this and not sure what I should pass for callback. I also want to trigger another lambda and pass these new variables to it.
exports.handler = function(event, context, callback) {
console.log("AWS lambda and SNS trigger ");
console.log(event);
const sns_NameSpace = event.Records[0].Sns.Message.Trigger.Namespace;
const sns_ApiId = event.Records[0].Sns.Message.Trigger.Dimensions.value;
const sns_MetricName = event.Records[0].Sns.Message.Trigger.MetricName;
console.log(sns_ApiId '_' sns_MetricName)
console.log(sns_NameSpace)
callback(null, sns); // Wondering what I should pass for the callback.
};
CodePudding user response:
If you have configured SNS -> Lambda trigger, you don't need to do anything to the callback. SNS sends a message to a subscriber (in this case a Lambda function) exactly once and does not wait for a response from the subscriber.
And what exactly do you mean by 'another lambda'?