Capture S3 events using Lambda Function and send status mail using SES
Posted on by Sumit Kumar
Dear Reader,
In this blog, I will tell you how to capture S3 events using Lambda function and send status mail to the required recipient using SES.
We will do it in three steps.
So let’s start……
Step:-1)
Create IAM Roles for Lambda Function so that the Lambda function can call AWS services.
Please remember Role Name(S3_Lambda), we are going to use it while creating the Lambda function.
One after creating the Role we will move to step 2 and let’s create the Lambda function.
Step:-2) Search for Lambda service and create Lambd Function.
After creating function go to Configuration Tab and write Lambda function to capture event occurs on S3 and send
mail to the required recipient.
then Save the Lambda Function.
Now, we will move to step 3 and create S3 Bucket and assign event notification using the Lambda function.
Step:-3) Create S3 Bucket:-
Search for S3 Service and follow the below screenshots.
then saveĀ Event notification.
we have selected two events, Post and All object delete events, that will call Lambda function whenever we will upload files into the bucket and delete the file from the bucket.
Lambda function will send mail to the mentioned recipient.
After uploading go to Lambda function monitoring Tab and View logs in cloudWatch.
In logs, you will find success and you will get mail notification for uploading the file.
Same way if you will delete the file you will get mail notification.
Note:- If you are using a free account you must have to verify your email ID using SES
If your mail ID is not verified you will get below error.
In this case, follow the below screenshots and verified your email address using SES.
After verifying your email ID via SES you will start receiving mail.
Hope this blog will be helpful for you.
Thank you!
Reference:-
Leave a Reply