Thursday, October 14, 2021

when EC2 instance changes states you will notify via Email in aws

In this tutorial we will configure a Cloudwatch event service with SNS topic.

 

Create an SNS topic

Step 1) Open the Amazon SNS console, and then choose Topics from the navigation pane.


 

Step 2) Choose Create topic >> Select Standard >> enter a name for your topic >> enter a display name for your topic >> Choose Create topic.


 

Step 3) On the Subscriptions tab, choose Create subscription.


 

Step 4) For Protocol, choose Email >> For Endpoint, enter the email address where you will receive the notifications >> Choose Create subscription.


 

Step 5) A subscription confirmation email is sent to the address which you have entered. Choose Confirm subscription in the email.


 

 

Create a CloudWatch event

 

Step 1) Open the CloudWatch console, and then choose Events from the navigation pane.


 

Step 2) Click on create rule >> choose Event Pattern >>
For Service Name, choose EC2 >> For Event Type, choose EC2 Instance State-change Notification.
Choose Any state >> Choose Any instance


 

Step 3) Choose Add target

For Targets, choose SNS topic >> For Topic, choose the topic name >> Click on configure details


 

Step 4) For Configure details.

For Name, enter a rule name >> For Description, enter a rule description >> Choose Create rule.


 

Now You can test the rule by starting or stopping an instance.
This rule generates an email notification every time an instance changes to any state, including stopped.


 

No comments:

Post a Comment

testing