August 3, 2018 / Nirav Shah
Amazon has not yet presented managed automated backups in EC2 service. It is only available in RDS service. But using CloudWatch Events we can configure automated snapshots for our EC2 volumes using Lamda functions or by calling EC2 CreateSnapshot API on the behalf of us.
Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications running on it. CloudWatch helps you to collect and track metrics for your AWS resources.
You can configure alarm to help you react when changes happen to your resources. For example, you can create a alarm when your EC2 instance is utilizing more CPU than the normal usage limit.
You can do more than creating alarm by leveraging the CloudWatch Events feature. In this tutorial, we are going to see the one such use case of CloudWatch Events where you can automate the EBS (Elastic Block Storage) snapshots creation.
A topic is a communication channel to send messages and subscribe to notifications. It provides an access point for publishers and subscribers to communicate with each other. In this section you create a topic named MyTopic.
To create a topic
To receive messages published to a topic, you have to subscribe an endpoint to that topic. An endpoint is a mobile app, web server, email address, or an Amazon SQS queue that can receive notification messages from Amazon SNS. Once you subscribe an endpoint to a topic and the subscription is confirmed, the endpoint will receive all messages published to that topic.
To subscribe to a topic
Now you have created a SNS topic and confirmed email address of end point. You will need this SNS topic to get alerts on automated backup status. In next steps you will learn how to take automated backups for EC2 volumes.
You have created an notification alert whenever any snapshot will be created. This will help us to know the status of the snapshot into subscriber’s email.
Now create new rule into events to create snapshots automatically in every fix rate of time (Example – Minute, Hours, Days)
Congratulations now you have successfully set up automated snapshots for your EC2 EBS volumes with SNS Notifications using CloudWatch Events.
1.Can you snapshot an EC2 instance?
2.Where are EC2 snapshots stored?
As a Director of Eternal Web Private Ltd an AWS consulting partner company, Nirav is responsible for its operations. AWS, cloud-computing and digital transformation are some of his favorite topics to talk about. His key focus is to help enterprises adopt technology, to solve their business problem with the right cloud solutions.
Have queries about your AWS project ideas and concepts? Please drop in your project details to discuss with our AWS experts, professionals and consultants.