I am using aws lambda function to convert uploaded wav file in a bucket to mp3 format and later move file to another bucket. It is working correctly. But there\'s a problem
The context object contains information on which request ID you are currently handling. This ID won't change even if the same event fires multiple times. You could save this ID for every time an event triggers and then check that the last ID you handled isn't the same as the current one.
Here's my final code to fix this issue (NodeJS with MongooseJS database handler):
exports.handler = function(event, context, lambdaCallback) {
Events.findOneAndUpdate(
{ name: 'some-event-name' },
{ lastRequestId: context.awsRequestId }).then(function(event) {
if(event.lastRequestId == context.awsRequestId) {
return;
}
/* Run the actual job */
...
});
}
Hope this helps!