# Amazon SNS

Amazon Simple Notification Service (Amazon SNS) sends notifications in two ways, A2A and A2P. A2A provides high-throughput, push-based, many-to-many messaging between distributed systems, microservices, and event-driven serverless applications. These applications include Amazon Simple Queue Service (SQS), Amazon Kinesis Data Firehose, AWS Lambda, and other HTTPS endpoints. A2P functionality lets you send messages to your customers with SMS texts, push notifications, and email. 

## How to work with SNS? Let's make it easy!

Here is a simple example, in which we are going to set an email alert if there are any changes in our EC2 instance.

### Step 1: **Configure Amazon SNS**

1. Search SNS and select it
    
2. Goto `Topics` on left bar
    
3. Click on **<mark>Create topic</mark>**
    
    * Select type `Standard`
        
    * Name: `EmailAlert`
        
    * Leave all default and `Create topic`
        
4. Goto `subscriptions` and select **<mark>Create subscription</mark>**
    
    * In Details Setting
        
        * Topic: Select `EmailAlert`
            
        * Protocol: Select `Email`
            
        * Endpoint: `your-email-address`
            
    * `Create subscription`
        
5. Now, Open your email, select the AWS Notification email and
    
    select `Confirm subscription`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686548914316/94ae9da9-75d7-4fab-935e-96e54bc1d22f.jpeg align="center")
    

### Step 2: Config Amazon EventBridge

### (Another form of CloudWatch)

EventBridge is a serverless service that uses events to connect application components together, making it easier for you to build scalable event-driven applications. Use it to route events from sources such as home-grown applications, AWS services, and third-party software to consumer applications across your organization. EventBridge provides a simple and consistent way to ingest, filter, transform, and deliver events so you can build new applications quickly.

1. Search EventBridge on the search bar and select it, Also click on Buses to expand
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686555079129/ebf435ec-02c1-418c-a123-e57054743a31.jpeg align="center")
    
2. Click on `Rules` then scroll down and click `Create rule`
    
3. Configure `Step1: Define rule detail` as:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686555277757/8d9d4207-8fcd-478f-84de-9eca007542da.jpeg align="center")
    
4. Configure `Step 2: Build event pattern` as:
    
    * Leave all defaults and scroll down to `Event pattern`
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686555545981/cc0e7490-c3b6-4beb-8406-d70d9be62732.jpeg align="center")
        
        \[ Don't panic: Select AWS service then Event type auto-generate \]
        
5. Configure `Step 3: Select target(s)` as:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686555769114/b880efdf-d548-4b79-91ea-5f9d406895b4.jpeg align="center")
    
6. Leave optional `Step 4: optional Configure tags`
    
7. `Step 5: Review and create` click on **<mark>Create rule</mark>**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686555897619/80fc7bd5-eb76-452a-ae99-afe19e164673.jpeg align="center")
    

### Step 3: Working with the EC2 state

* In the EC2 instance anything you do with instance i.e. Create, stop, Terminate you will receive an alert email.
    
* For example, let's launch an EC2 instance without any special setup only with the name and existing key leaving all default.
    
* You receive an email like this:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686556504295/adee7ce4-5880-4fe7-8491-9d9175148ce5.jpeg align="center")
    

Don't forget to terminate all the things you created !!!

# Thanks for Learning the SNS config...
