- Lab
- A Cloud Guru
Configuring SNS Push Notifications on S3 Bucket Events Inside of the AWS Console
In this live AWS environment, you will configure an S3 bucket to trigger AWS Simple Notification Service notifications whenever an object is added to an S3 bucket. This scenario will help you understand how you can architect your application to respond to S3 bucket events using other services such as SNS, AWS, Lambda, and others.
Path Info
Table of Contents
-
Challenge
Create an S3 Bucket
Create an S3 bucket inside the AWS console:
- Navigate to the S3 portion of the console.
- Click Create Bucket.
- Give your bucket a unique name and continue to create the bucket without adding additional configuration.
-
Challenge
Create an SNS Topic
Navigate to the Simple Notification Service portion of the AWS Console and create an SNS Topic:
- Go to the SNS dashboard in the AWS Console.
- Create an SNS Topic.
- (Eventually) edit the topic's resource policy so that the S3 bucket will be able to send events to that topic.
Ignore any KMS errors - the error won't impact the Hands-On lab.
-
Challenge
Configure the Bucket — Part 1
Setting up events allows us to receive notifications whenever there are events happening in our bucket that we want to be notified about.
Navigate back in the S3 Management Console:
- Configure your bucket settings.
- Event name: "S3ObjectCreated".
We'll then receive an error: "Unable to validate the following destination configurations. Permissions on the destination do not allow S3 to publish notifications from this bucket." The reason we got this is because we haven't yet configured our SNS topic policy to accept notification events from our S3 bucket. Let's do that now.
-
Challenge
Modify the SNS Topic Policy
Navigate to Simple Notifications Services Console.
Add the following code:
{ "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": "SNS:Publish", "Resource": "SNS_ARN_REPLACE_ME", "Condition": { "StringEquals": { "aws:SourceArn": "S3_BUCKET_ARN_REPLACE_ME" } } },
In the
SNS:Publish
section, where it says,SNS_ARN_REPLACE_ME
, paste in the SNS topic you added to that text file or note a minute ago. Then, copy and paste your S3 bucket ARN where it saysS3_BUCKET_ARN_REPLACE_ME
.Make sure to leave the comma after the last bracket in our new statement, as this allows us to have more than one statement for this SNS topic's policy.
Create the Bucket - Part 2
Navigate back in the S3 Management Console.
- Configure bucket settings again.
This time, we should see we now have one active notification.
-
Challenge
Create the Email Subscription and Create the SMS Subscription
Create the Email Subscription
- Navigate to Simple Notification Service.
- Configure email settings.
- Accept confirmation AWS email from inbox.
- If successful, subscription confirmation page will appear.
Create the SMS Subscription
- Navigate to SNS Topics.
- Select S3Events.
- Insert "HELLO" under Subject-optional.
- Insert "This is a test message" under Message body.
- Save changes.
- If successful, Amazon S3 Notification email sent to your inbox.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.