Simple Notifications Service known as SNS is a service that allows you to automate the sending of emails or text message notifications based on events that happen in your AWS account.

SNS has 3 basic components:

1. Topics - how you label and group different endpoints that you send messages to
2. Subscriptions - the endpoint that a topic sends messages to (e.g., email address of the administrator)
3. Publishers - the human/alarm/event that gives SNS the message that needs to be sent

SNS can be setup to work and be triggered by multiple different AWS services and it sends notifications to subscribers of topics via multiple protocols, eg. HTTP, Email, SMS.

Publishers communicate with subscribers by producing and sending a message to a topic, which is a communication channel.

Subscribers (i.e. , Web Servers, Lambda Functions, Email addresses) consume or receive the message or notification over one of the supported protocols.

How to create a topic and make it trigger an event?

So we first go to the AWS Management Console, log in, and then from services pick SNS. After that we open the Topics tab and there is Create Topic button on the right side of the window

To assign a certain event to a topic, for example S3 buckets, All Object Create and All Object Delete events, you navigate to S3 from Services, click on a bucket and from there choose Properties and then Events. When you open events, you can see this sort of window:

From there as selected above, you select the events that you want to get triggers from, and you choose to receive those notifications about the events through SNS Topic by selecting the exact topic from which you want to receive them from.

On the other hand SES stands for Simple Email Service which is cloud based service for sending emails.

How SES works is that a Client Application acting as an email sender makes a request to Amazon SES to send an email to one or more recipients. If the request is valid Amazon SES composes an email message based on the request parameters and then queues it for delivery. The message is then routed to the receiver ISP.

The first step to enable SES is to verify a new domain. You can do that by navigating to SES from Services and choosing Domains from the left panel. After that click on the Verify a New Domain button and add your domain.

SES provides you with an MX record for your domain. An MX record is what sending email servers use to look up the mail server to deliver messages to for a given domain. You add this DNS record in your domain’s DNS settings. If you use Route53 for the domain’s DNS, you can select ‘Use Route 53’ to automatically add the record.

If you want to store the emails you receive into a S3 bucket, you need to give Amazon SES permissions to write to that bucket. An example policy can be found on this link.

So you navigate to S3, click on a bucket that you created in which you want to store the emails, click Permissions and then Bucket Policy. In there paste the policy from the link above.

You need to change BUCKET-NAME, to be the name of your bucket and also the AWSACCOUNTID to be the ID of your AWS Account.

So far we have verified the domain, published the MX record and set up the S3 bucket to store the messages, now we need to define the receipt rules.

To do that, in SES under Email Receiving, we choose Rule Sets and then Create a Receipt Rule. Here we define from whom we want to receive messages from.

Leaving the Recipient field blank, means the rule applies to all messages sent to the domain. The next step are the Actions you want Amazon SES to perform when receiving a message. For example to store the email in S3 bucket, as an action you should choose S3 and then the name of the bucket.

In this manner, you can use SNS and SES effectively.

soc analyst serving tech bites as articles.