Skip to main content

Cloud

Create S3 Event Notification using AWS Lambda Function

A group of diverse coworkers working on the computer together

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 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, select S3 service, and click on the create bucket option.

1 .s3 Service

Put bucket name and click on create bucket at the bottom of create bucket page.

2. Name S3 Bucket

3. Create Bucket

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.

4. Lambda Service

Then Click on create function, Click on the “Use a Blueprint” option, search for “s3-get-object-python,” select it and click on configure.

5. Create Function

6. Blueprint

Now provide the function name here. For the execution role, I’m choosing the first option.

7. Function Name

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.

8. Lambda Function Code

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.”

9. Create Event Notofocation

Now provide the event name and select different events according to your requirements.

10. Types Of Event

Select the lambda that you have created in the lambda function and save changes.

11. Create Event Notification

As a result, now you can see event notifications created for the s3 bucket.

12. Event Notification

 

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 Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Ahmad Raza Kaliwala

Ahmad Raza Kaliwala is an Technical Consultant at Perficient. He has over one year of experience in ETL Development and Testing. He has exposure to ETL tools like AWS Glue, SSIS, and Azure Data Factory.

More from this Author

Categories
Follow Us