Updated: Oct 17
a. Learn to set EventBridge notifications for state change in EC2 instances
In AWS Management Console, go to EC2 and create 2 Linux instances. For step-by-step guide to create instances refer to this blog.
Create an SNS topic named MyTopic. Refer to this blog (Step 1,2 and 3) for guidance. In Subscriptions Select Email instead of Email-JSON in Protocol.
Go to EventBridge and click on Rules, Create rule. Give the Name as MyEC2StateChangeEvent and a suitable description. Click on Next
In Build event pattern, under Sample event select EC2 Instance State-change Notification and under Event pattern select EC2 from AWS service and EC2 Instance State-change Notification in Event type. Click on Next.
In Select Target select SNS Topic and the topic we created in Step 2 from dropdown. Click Next till you get to Review and create and Create rule.
Stop the first instance and check the email address specified in the SNS topic. You should have received a mail from SNS topic specifying that instance has stopped.
Now Terminate the second instance. Again you should receive a mail informing about the termination of the instance.
Note: After you have finished, remove the SNS, EventBridge and EC2 instances.
Was this document helpful? How can we make this document better. Please provide your insights. You can download PDF version for reference.
For your aws certification needs or for aws learning contact us.