Amazon SNS

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 Create topic

    • Select type Standard

    • Name: EmailAlert

    • Leave all default and Create topic

  4. Goto subscriptions and select Create subscription

    • 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

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

  2. Click on Rules then scroll down and click Create rule

  3. Configure Step1: Define rule detail as:

  4. Configure Step 2: Build event pattern as:

    • Leave all defaults and scroll down to Event pattern

      [ Don't panic: Select AWS service then Event type auto-generate ]

  5. Configure Step 3: Select target(s) as:

  6. Leave optional Step 4: optional Configure tags

  7. Step 5: Review and create click on Create rule

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:

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

Thanks for Learning the SNS config...