Email Notification On Uploading Files To S3 Bucket

Introduction 

Today we are going to learn how we can receive an email notification on files uploading to the S3 bucket in AWS.

S3 Bucket

S3 Stands for Simple Storage Service and it is a cloud storage service available in AWS. Basically, S3 in Amazon has two entities, objects, and buckets. Objects are stored inside buckets and every organization needs a file system to store their unstructured files, that's why AWS introduced a file system called S3. In my last article, we already learned how to create and access an S3 bucket here 

In this, we are using the AWS SNS(Simple Notification Service) that enables you to set up, operate, and send the notifications from the cloud directly to the customer so here we notify the customer via email when files are uploaded to the S3 bucket

Setting up SNS

Step 1 - Create an SNS Topic

Email Notification On Uploading files to S3 Bucket

  • In the Create new topic screen, enter a name for the topic
  • You need to select the type between standard and FIFO, it is just the type of order while sending the notifications one after another for now we are going with the default standard.

Copy the Topic ARN for the next task

Step 2 - Subscribe to an SNS topic

  • Open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home
  • Choose Subscriptions, then Create a subscription
  • Paste the Topic ARN that we copied in the last step 
  • Choose Email protocol
  • For Endpoint, enter an email address where you want to receive the notification,
  • Then choose to Create a subscription.

Email Notification On Uploading files to S3 Bucket

After this, you will receive a confirmation subscription email where you need to confirm the subscription if you do not confirm this your subscription is in a pending state.

Step 3 - Create an event 

Now create an event for which s3 bucket you want to receive the notifications

  • In the Buckets list, choose the name of the bucket for which you want to enable the notifications.
  • Choose Properties and In-event notifications.
  • Create event notifications

Email Notification On Uploading files to S3 Bucket

  • Enter the name of the event
  • Choose event - All objects create an event, which you can select as per your requirement 
  • Select an SNS topic in Send to and 
  • Select a topic name in SNS, and click on save changes.

Try to upload a file to the bucket - 

Email Notification On Uploading files to S3 Bucket

Email Notification On Uploading files to S3 Bucket

Summary

In this way, we can create a notification alert while files are uploaded to S3 Bucket and you can customize your alerts according to your requirements. 

I hope you like this article. Stay safe and learn more!