Amazon S3 Event Notifications

With Amazon S3 being virtually unlimited in size, it’s quite a challenge to keep everything monitored especially when you are dealing with a large number of objects that scales up from time to time.

With Amazon S3 Event Notifications, you’ll be able to immediately know when an object in your bucket was created, removed or restored. This feature allows you to get notifications every time an event happens on your S3 bucket. These notifications can then be forwarded to Amazon Simple Notification Service (Amazon SNS) topic, Amazon Simple Queue Service (Amazon SQS) queue, and AWS Lambda. The S3 Event Notification feature supports multiple events like new object creation, object removal, object restoration, object loss as well as replication events for objects with S3 Replication Time Control (S3 RTC) enabled.

Configuring Amazon S3 Event Notifications

IT Certification Category (English)728x90

Let’s try a real-world application of this. Let’s say we want to receive an email notification every time an object is uploaded or removed from our bucket. To do this, we will need to configure our bucket to send a notification to SNS Topic, which will push an email notification to us.

Here, I created an SNS Topic named “S3EventNotification” with a configured access policy allowing S3 service to publish messages on SNS Topic. 

Access Policy

{
  "Version": "2008-10-17",
  "Id": "example-ID",
  "Statement": [
    {
      "Sid": "s3-event-notifier",
      "Effect": "Allow",
      "Principal": {
        "Service": "s3.amazonaws.com"
      },
      "Action": "SNS:Publish",
      "Resource": "arn:aws:sns:ap-southeast-1:947117271373:S3EventNotification",
      "Condition": {
        "ArnLike": {
          "aws:SourceArn": "arn:aws:s3:::repo-load-script"
        }
      }
    }
  ]
}

Once you have your SNS Topic, create a subscription using your email address. Don’t forget to verify your email.

Amazon S3 Event Notifications1

Next, we need to configure events on our bucket. For this example, I have an empty bucket named repo-load-script.

Amazon S3 Event Notifications2
Go to Property Tab > Advanced Settings and select Events. You can select multiple events as triggers. For now, let’s select All object create events and All object delete events. Select SNS Topic as destination, choose a Topic, then click save.

Amazon S3 Event Notifications3

Let’s try uploading a text file to our bucket and let’s see if we are able to receive an email notification.

Amazon S3 Event Notifications4
Here’s the email notification received after uploading and deleting it. It contains necessary information like Event Name and Time, Bucket and Object Name, User Identity, and Source IP Address which are pretty helpful when investigating incidents like object deletion.

Amazon S3 Event Notifications5Final Thoughts

The Amazon S3 Notification feature is a simple yet effective way of monitoring bucket events. This can also be useful in processes that are dependent on bucket events. You have an option to send it to SNS topic (which we just did), trigger a Lambda Function, or send it to SQS queue which then can be consumed by another process later on. 

Sources:

https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
https://docs.aws.amazon.com/AmazonS3/latest/dev/ways-to-add-notification-config-to-bucket.html

***

AWS Certifications are consistently among the top paying IT certifications in the world, considering that Amazon Web Services is the leading cloud services platform with almost 50% market share! Earn over $150,000 per year with an AWS certification!

Subscribe to our newsletter and notifications for more helpful AWS cheat sheets and study guides like this and answer as many AWS practice exams as you can.🙂

Pass your AWS Certifications on your First Try with the Tutorials Dojo Portal

Tutorials Dojo portal

Our Bestselling AWS Certified Solutions Architect Associate Practice Exams

AWS Certified Solutions Architect Associate Practice Exams

Enroll Now – Our AWS Practice Exams with 95% Passing Rate

AWS Practice Exams Tutorials Dojo

Tutorials Dojo Study Guide and Cheat Sheets eBooks

Tutorials Dojo Study Guide and Cheat Sheets-2

FREE AWS eBook for Beginners

AWS eBook Tutorials Dojo

FREE AWS Practice Test Samplers

Browse Other Courses

Generic Category (English)300x250

Recent Posts