AWS EBS Snapshots: Using AWS Cloud watch Events
We will setup EBS snapshots using cloud watch events, in this example we will set up snapshots on daily basis. EBS snapshots are backup of EBS volumes, snapshots are incremental in nature and stored in S3 by AWS.
We will get started by creating a new SNS topic and SNS e-mail subscription that we will use for notification with our CloudWatch event rule, not necessary but good to have:
Navigate to the SNS section of the AWS console
On the left-hand side pane click on Topics then Click “Create Topic”
On the left-hand side pane click on Subscriptions then Click “Create Subscription”
Configure an “email” subscription sending a message to your email. Check your email for an email like below and confirm it.
Create the CloudWatch Event Rule that will once-daily snapshot the specified EBS volume, and initiates an email via SNS
Navigate to EC2 -> Elastic Block Store -> Volumes, and copy a volume-id to your clipboard
Navigate to CloudWatch and click Events -> Rules
Click “Create Rule” at the top of the console, Select “Scheduled”, and make the recurrence “1, days” for once per day (can be based on individual preference)
Add a target of “EC2 Create EBS Snapshot API call”, and paste in volume-id from clipboard, Select “Create a new role for this specific resource” (this will assign necessary IAM policies to the role)
Add a target of “SNS Topic” and select our newly created SNS topic, Configure the Rule with a name, and Save the rule.
Confirm that your new CloudWatch Event Rule is working as expected by checking that a new EBS snapshot was created.
Confirm in your email for the message from SNS
Check in EC2 -> Elastic Block Store -> Snapshots that a new snapshot has been created