Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Email notifications when ec2 instance in terminated

I need to receive notifications whenver my instance in terminated. I know it can be done by cloudtrail and then using sns and sqs to get email for it, if you receive event of termination.

Is there a simpler way to do that ?

Any solution will is appreciated, but I prefer is doing using boto.

like image 330
Sumit Murari Avatar asked Jan 24 '26 22:01

Sumit Murari


1 Answers

While it is not possible to receive a notification directly from Amazon EC2 when an instance is terminated, there are a couple of ways this could be accomplished:

Auto Scaling can send a notification when an instance managed by Auto Scaling is terminated. See: Configure Your Auto Scaling Group to Send Notifications

AWS Config can also be configured to send a Simple Notification Service (SNS) notification when resources change. This would send many notifications, so you would need to inspect and filter the notifications to find the one(s) indicating an instance termination. See the SNS reference in: Set Up AWS Config Using the Console and Example Amazon SNS Notification and Email from AWS Config.

Amazon Simple Notification Service (SNS) can also push a message to Amazon Queueing Service (SQS), which can be easily polled with the boto python SDK.

Receiving notifications via CloudTrail and CloudWatch Logs is somewhat messier, so I'd recommend the AWS Config method.

like image 176
John Rotenstein Avatar answered Jan 26 '26 22:01

John Rotenstein