Wednesday, October 18, 2017

Getting notified for any state change in the AWS resources (like EC2 going down)

EC2 can be used for any purpose like running a website, doing some batch processing. A website has a requirement to run 99.9 or 99.99 or some other percentage of the time, so back up of the EC2 instances are required for the sake of high availability. But, lets take the case of batch as in the case of transforming 1000's of records from one format to another, then high availability is not really important. If an instance fails then another can be started or the work can be automatically shifted to some other instance automatically as in the case of Big Data.

Just to quickly summarize, in the case as in the case of web servers we need some level of high availability and so multiple EC2 instances (backup), but in the case of batch processing there is no need of backup. Lets take the case of a batch job running on a single EC2 instance, it would be good to get some sort of notification when the instance goes down. We would be looking into the same in this blog. We would be using EC2, SNS and CloudWatch. So, it would be a good way to get familiar with the different topics.

So, here are the steps.

Step 1: Create a new topic in the SNS management console.

Step 2: Subscribe to the topic created in the previous step.

Step 3: You should be getting an email with a link, click on it to confirm the subscription and the status of the subscription changes on refreshing the screen.

Step 4: Start a Linux EC2 instance as mentioned here and note down the instance id.

Step 5: Create a rule in the Cloud Watch Management Console for the appropriate instance and the events.

Step 6: Perform different actions on the EC2 and you will notice that you would be getting an email.

Note that the above procedure can be used for getting a notification of any state changes in the AWS resources.

1 comment: