We will learn how to create S3 event notifications using AWS Lambda functions in this blog.
Firstly, we will get acquainted with AWS S3 Event Notification and briefly explain AWS Lambda Functions.
AWS S3 Event Notification
Using Amazon S3 Event Notifications, you can be notified when certain events occur in your S3 bucket. Configure Amazon S3 to publish events that you want to be notified about with a notification configuration. It should also identify the destinations to which notifications should be sent from Amazon S3. You store this configuration in the notification sub-resource that’s associated with a bucket.
Overview of Amazon S3 Event Notifications
Amazon S3 can currently publish notifications for the following events:
New object-created events.
Object removal events.
Restore object events.
Reduced Redundancy Storage (RRS) object lost events.
Replication events.
S3 Lifecycle expiration events.
S3 Lifecycle transition events.
S3 Intelligent-Tiering automatic archival events.
Object tagging events.
Object ACL PUT events
AWS Lambda Function
Run functions on demand without the servers.
Supports many languages (Python, Java, Go, Ruby, etc).
Adhoc task or completely serverless high TPS Applications.
Pay per invocation, duration, and memory.
Built-in metrics with AWS CloudWatch
Creation of S3 Event Notification using AWS Lambda Function
At the very first, create an s3 bucket. Open AWS Management Console and select S3 service and click on create bucket option.
Put bucket name and click on create bucket at the bottom of create bucket page.
So S3 bucket has been created, and now we will create the AWS Lambda function, for that search for Lambda service on AWS Management Console.
Then Click on create function Click on the “Use a Blueprint” option, search for “s3-get-object-python” select it and click on configure.
Now provide the function name here. For the execution role, I’m choosing the first option.
Note:- As of now, I’m not going to add the S3 bucket as a trigger. Remove the trigger. Now, at the bottom of the page, the piece of code for lambda is available, you can change it according to requirements. Click on Create Function.
So, the lambda function is ready. Now I’ll go to the s3 bucket that I’ve created. In Properties, there is a section for Event Notification. click on “Create Event Notification”.
Now provide the event name and select different events according to your requirements.
Select the lambda that you have created in the lambda function and save changes.
As a result, now you can see event notifications created for the s3 bucket.
In this blog, we have covered the creation of event notifications on the S3 bucket. To learn more about Amazon S3 event notifications click here.
Leave A Comment