Skip to main content

AWS S3: Upload Notification

242 words·
AWS S3 Mail Notification
Table of Contents

Copy Amazon Resource Name (ARN) of S3 bucket
#

Create SNS Topic
#

Go to Simple Notification Service (SNS) and create a now Topic. The SNS region must be the same as the s3 bucket region.

Use standard type, give the topic a name and create the topic.

Create a SNS Subscription
#

After the topic is completed, copy the topic ARN and create a subscription for the topic.

Choose Email as protocol, provide your email address as endpoint and create the subscription.

Open your mailbox and confirm the subscription. The Status of your SNS subscription should change from pending to confirmed.

Change the Access Policy of your topic
#

Edit the topic that you have created amd go to Access Policy. Replace the default policy with the following policy:

{
    "Version": "2012-10-17",
    "Id": "example-ID",
    "Statement": [
        {
            "Sid": "Example SNS topic policy",
            "Effect": "Allow",
            "Principal": {
                "Service": "s3.amazonaws.com"
            },
            "Action": [
                "SNS:Publish"
            ],
            "Resource": "SNS-topic-ARN",
            "Condition": {
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:s3:*:*:bucket-name"
                },
                "StringEquals": {
                    "aws:SourceAccount": "bucket-owner-account-id"
                }
            }
        }
    ]
}

Change SNS-topic-ARN, arn:aws:s3:*:*:bucket-name and bucket-owner-account-id. Click save changes.

Create am Event Notification for the S3 bucket
#

Open the properties section of the S3 bucket and add an Event Notification.

Name the Event Notification and choose All object create events

Choose SNS topic as destination and select the SNS topic that you have created. Save the changes and upload a file to the S3 Bucket to test the notificaion system.