Saturday, 9 September 2023

AWS SNS (Simple Notification Service)

 Integration of SNS service with S3 service.


Step 1: In AWS console search for SNS service. In SNS console under Create topic give Name as MyTopic. Click on Next Step.

Give Display name: MyDisplay

Scroll down and open the Access Policy – optional drop down.

Under Define who can publish messages to this topic click on Everyone radio button.

Under Define who can subscribe to this topic click on Everyone radio button.

Click on Create topic in bottom right corner.

Confirm the creation of this topic in SNS Console.


Step 2: Click on the created topic MyTopic. Scroll to Subscriptions. Click on Create subscription.

Under Details select Protocol: Email-JSON and in Endpoint provide e-mail ID of subscriber. For testing purposes preferably your own e-mail ID.

Click on Create subscription.


Step 3: Go to the endpoint e-email Inbox. An email is received to confirm the subscription. Click on the provided SubscribeURL.

Check in the SNS Console Subscription. The status will display Confirmed.


Step 4: Go to Amazon S3 services and click on Create bucket.

Provide bucket name as bucketforsns and click on Create.

Upload 2 images inside the bucket.


Step 5: Go to the Properties of this bucket. Scroll down and select Events.

Click on +Add notification.

Provide Name as MyNotificationS3Delete.

Under Event select Permanently Delete checkbox.

In the Send to drop down select SNS Topic.

In SNS drop down, select the MyTopic created in above steps.

Click on Save.

An email would be received about this notification.


Step 6: Go to the bucket and select any one image object. Select Actions -> Delete.

SNS service will provide you with notification about deletion on an S3 object through Mail.


Note: Delete the bucket and SNS Topic if you no longer need it.

No comments:

Post a Comment