I tried to track Amazon EC2 termination event

2022.07.30

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Overview

In this article, we used Cloudwatch Events to send instance state change notification events to SNS Topic.
Here we have created a CloundWatch Events rule that will send an event to an SNS Topic
when an Amazon EC2 instance gets Terminated.
Resources to create:

SNS Topic CloudWatch Events EC2 Instance

I tried

  • Let's, Create an EC2 instance
    • This time I am creating an EC2 Instance with Basic Configuration

  • Create an SNS Topic with an email address you have access to
    • In Protocol I am choosing Email and in endpoint, we can use our Email Address(xxx@xxx.com)
    • After Creating a Subscription it is needed to Confirm the Email you Can go to your inbox you will find AWS Notification
    • click the link and you will successful message

  •  Create CloudWatch Event Rules
    • Open CloudWatch> Events>Rule

  1. Create Rules

Fill in the detail as shown in Screen Shot below

Select the SNS topic we Created Before

Then Click Configure Details

 

Your Event pattern Preview should look like this 
 

{ "source": [ "aws.ec2" ], "detail-type": [ "EC2 Instance State-change Notification" ], "detail": { "state": [ "terminated" ] } } 

[ /code]

 

Let’s Test

    1. Delete the instance

    2. Check the email

At The End

This time I have created a CloudWatch Event rule for EC2 State Change to termination and get the email. we can use the same process and can receive SMS on mobile for EC2 Start, Stop State Change and many other Services. Hope this Blog is helpful.