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
Search SNS and select it
Topicson left bar
Click on Create topic
Leave all default and
subscriptionsand select Create subscription
In Details Setting
Now, Open your email, select the AWS Notification email and
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.
Search EventBridge on the search bar and select it, Also click on Buses to expand
Rulesthen scroll down and click
Step1: Define rule detailas:
Step 2: Build event patternas:
Leave all defaults and scroll down to
[ Don't panic: Select AWS service then Event type auto-generate ]
Step 3: Select target(s)as:
Step 4: optional Configure tags
Step 5: Review and createclick 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 !!!