Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SNS notification for ec2 instance creation and termination

I would like to get notified via email, whenever an ec2 instance is created/terminated in my AWS account. How can I achieve this?

like image 258
LogicIO Avatar asked Jan 12 '18 12:01

LogicIO


People also ask

Can a user get a notification of each instance of start or terminate configured with auto scaling?

Question 5: Can a user get a notification of each instance start / terminate configured with Auto Scaling? Explanation:The user can get notifications using SNS if he has configured the notifications while creating the Auto Scaling group.

How do I set up SNS notifications?

To set up an SNS topicSubscribe your email address to the topic using the subscribe command. If the subscription request succeeds, you receive a confirmation email message. From your email application, open the message from AWS Notifications and confirm your subscription.

What two options are available to alert tenants when an EC2 instance is terminated?

Using Amazon CloudWatch alarm actions, you can create alarms that automatically stop, terminate, reboot, or recover your EC2 instances. You can use the stop or terminate actions to help you save money when you no longer need an instance to be running.


1 Answers

The easiest method (IMO) to do that is to use CloudWatch Events service along with an SNS topic configured to send out emails to your email ID.

In AWS web console, go to CloudWatch -> Events (On left panel) -> Rules -> 'Create rule'

In 'Event Source' choose 'Event Pattern'. Then choose 'Events By Service'. In front of 'Service Name' select 'EC2' and for 'Event Type', select 'EC2 Instance State-change Notification'. You can either choose 'Any State' to get a notification on every state-change or choose specific state you are interested in ('Running' and 'Terminated'|'Stopped' might be of your interest). On the right, Click 'Add target' and then choose 'SNS topic' from dropdown. Then choose an SNS topic that you have configured already to send notification emails to your email ID.

enter image description here

Hope this helps!

like image 184
Furhan S. Avatar answered Jan 14 '23 23:01

Furhan S.