I’m using an AWS Lambda function (written in python) to send an email whenever an object is uploaded into a preset S3 bucket. The object is uploaded via the AWS PHP SDK into the S3 bucket and is using a multipart upload. Whenever I test out my code (within the Lambda code editor page) it seems to work fine and I only get a single email.
But when the object is uploaded via the PHP SDK, the Lambda function runs twice and sends two emails, both with different message ID’s. I’ve tried different email addresses but each address receives exactly two, duplicate emails.
Can anyone guide me where could I be going wrong? I’m using the boto3 library that is imported with the sample python code to send the email.
Advertisement
Answer
Yes, we have this as well and it’s not linked to the email, it’s linked to S3 firing multiple events for a single upload. Like a lot of messaging systems, Amazon does not guarantee “once only delivery” of event notifications from S3, so your Lambda function will need to handle this itself.
Not the greatest, but doable.
Some form of cache with details of the previous few requests so you can see if you’ve already processed the particular event message or not.