What I want to achieve: I receive emails through AWS SES and save them in AWS S3. Then the emails are processed by AWS Lambda, the result is stored in the database. Lambda is called by S3 when creating a new object.
Problem: only one part (I would say less than 10%) of letters is in my database.
On S3, I installed Event Notification . It calls my lambda function on ObjectCreated (All) . In my opinion, this means that for every new object created on S3 (i.e.Email stored by SES), the lambda function is called.
The lambda function does a few things, but at least it does it here:
exports.handler = function(event, context) { Async.mapSeries(event.Records, function dealWithOneMail(record, callback) { var srcKey = decodeURIComponent(record.s3.object.key.replace(/\+/g, " ")); console.log('> Working on object ' + srcKey); } }
As you can see, I iterate over the Records array in event and at least print the name of the object once. I also do this in the first line of my Lambda code:
console.log('> Lambda function invoked!');
Judging by my logs, the Lambda function is always called not , but only sometimes. Why do I think so?
I have downloaded all new emails from today, these are 1,245 objects. All these emails are also stored on S3. But I find 85 times the Lambda function invoked in my CloudWatch logs that were configured for Lambda automatically.
Does anyone have a clue what could be a mistake or even an idea that I could debug?