> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create automatic snapshot of EBS volume using Amazon DLM

> Hands-on lab · 30m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab details

1. This lab walks you through the steps to launch and configure a virtual machine in the Amazon cloud for the purpose of automating the creation of EBS Snapshots attached to this EC2 Instance every hour.
2. You will practice using Amazon Data lifecycle manager to create an EBS Snapshot policy with a custom duration of 1 hour using cron.
3. Duration: **90 minutes**
4. AWS Region: **US East (N. Virginia) us-east-1**

### Introduction

#### What is Amazon Data Lifecycle Manager (DLM)?

* DLM is used to manage the lifecycle of AWS resources.
* DLM helps to automate the creation, retention, and rotation of EBS Volumes, EBS Snapshots, and EBS-backed AMIs.
* Using the capabilities of CloudWatch events and CloudTrail, it provides the backup of EBS volumes attached to EC2 Instances at no additional cost.
* It cannot be used to automate the creation, retention, and rotation of instance store-backed AMI.
* Automating the EBS Volumes helps you in the following things:

  * Protects your data as you have the latest backup.
  * Create AMI with the latest data, apps, and software already present in it.
  * Meet the compliance requirement by retaining the backups.
  * Reduce storage costs by deleting outdated backups.
* **For this lab, you will have to wait for an hour after creating the Snapshot policy.**
  **AWS Documentation link:** [**https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/snapshot-lifecycle.html**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/snapshot-lifecycle.html)

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/001.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=2e5c8a2a49e024465cf4497a1a8b7d17" alt="" width="1768" height="198" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/001.png" />

#### What is EC2?

* AWS defines it as Elastic Compute Cloud.
* It’s a virtual environment where “you rent” to have your environment created, without purchasing.
* Amazon refers to these virtual machines as Instances.
* Preconfigured templates can be used to launch instances. These templates are referred to as images. Amazon provides these images in the form of AMIs (Amazon Machine Images).
* Allows you to install custom applications and services.
* Scaling of infrastructure i.e., up or down is easy based on the demand you face.
* AWS provides multiple configurations of CPU, memory, storage, etc., through which you can pick the flavor that's required for your environment.
* No limitation on storage. You can pick the storage based on the type of instance that you are working on.
* Temporary storage volumes are provided, which are called Instance Store Volumes.  Data stored in this gets deleted once the instance is terminated.
* Persistent storage volumes are available and are referred to as EBS (Elastic Block Store) volumes.
* These instances can be placed at multiple locations which are referred to as Regions and Availability Zones (AZ).
* You can have your Instances distributed across multiple AZs i.e., within a single Region, so that if an instance fails, AWS automatically remaps the address to another AZ.
* Instances deployed in one AZ can be migrated to another AZ.
* To manage instances, images, and other EC2 resources, you can optionally assign your own metadata to each resource in the form of tags.
* A Tag is a label that you assign to an AWS resource.  It contains a key and an optional value, both of which are defined by you.

### Architecture diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/002.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=89d612d74f470e9cb05e2e5b33b87039" alt="" width="1370" height="1128" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/002.png" />

### Task details

1. Sign in to AWS Management Console
2. Launching an EC2 Instance
3. Create an EC2 Snapshot policy using Lifecycle Manager
4. Wait for an hour
5. Check the automated snapshot
6. Validation of the Lab
7. Deleting AWS Resources

### Launching the lab environment

1. To launch the lab environment, Click on the **Launch lab** button.
2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
3. Once the Lab is started, you will be provided with **IAM user name**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

<Note>
  You can only start one lab at any given time
</Note>

## Lab guide

### Lab steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open console** button, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

   * Leave the Account ID as default. Never edit/remove the 12-digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
   * Now copy your **User Name** and **Password** in the Lab Console to the **IAM Username and Password** in AWS Console and click on the **Sign in** button.
3. Once Signed In to the AWS Management Console, Make the default AWS Region as **US East (N. Virginia) us-east-1.**

#### Task 2: Launching an EC2 Instance

1. Make sure you are in the US East **(N. Virginia) us-east-1** Region.
2. Navigate to EC2 by clicking on the **Services** menu at the top, then click on **EC2** in the **Compute** section.
3. Navigate to **Instances** on the left panel and click on **Launch instance** Button\*\*.\*\*
4. Name: Enter ***MyEC2***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/003.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=c8d0e44e7f5ac5fadf413b0152008389" alt="" width="964" height="193" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/003.png" />

5. **For Amazon Machine Image (AMI):** Search for **Amazon Linux 2023 kernel-6.1 AMI** in the search box and click on the **Select** button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/004.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=e022f4e65a3460f04ba24b119a4eb2f9" alt="" width="1179" height="609" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/004.png" />

6. **For Instance Type:** select ***t2.micro***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/005.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=1b694caadae7deb9f3612e349e40b6a5" alt="" width="971" height="260" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/005.png" />

7. **For Key pair:** Select **Create a new key pair** Button

   * Key pair name: **MyEC2Key**
   * Key pair type: **RSA**
   * Private key file format: **.pem**
8. Select **Create key pair** Button.
9. In Network Settings Click on **Edit** Button:

   * Auto-assign public IP: **Enable**
   * Select **Create new Security group**
   * Security group name: Enter **MyEC2Server\_SG**
   * Description: Enter ***Security Group to allow traffic to EC2***
10. SSH rule will be selected by default

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/006.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=5a48cdfd02fcf5720c868b5a4b93167b" alt="" width="1660" height="990" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/006.png" />
11. Keep the Rest thing Default and Click on **Launch Instance** Button.
12. Select **View all Instances** to View the Instance You Created
13. **Launch Status:** Your instances are now launching, Navigate to the **Instances** page from the left menu and wait for the status of the EC2 Instance change to **running** and the health check status change to **2/2 checks passed**.

#### Task 3: Create an EC2 Snapshot policy using Lifecycle Manager

1. Make sure you are in **US East (N. Virginia) us-east-1** Region.
2. Navigate to EC2 by clicking on the **Services** menu at the top, then click on **EC2** in the **Compute** section.
3. Navigate to **Elastic Block Store** on the left panel and click on **Lifecycle Manager.**
4. If the Policy type is selected as **EBS Snapshot policy**, click the **Next step** button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/007.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=8a736610f33742241a15eb8a346b5083" alt="" width="352" height="167" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/007.png" />
5. Targeted resource:

   * Target resource type: Select the **Instance**
   * **Note:** Selection resource type as Volume, will only create, retain, and rotate for that volume. But with the Instance type, you will get an automated snapshot of each volume attached to that EC2 Instance.
   * Target resource tags: Enter key as ***Name*** and Value as ***MyEC2***
   * Click on the **Add** button.
6. Description: Enter ***This snapshot policy will create an automated snapshot of EC2 volume every 1 hour***
7. IAM role: Select **Choose another role** and from the dropdown pickup the IAM Role starting with **task270\_role\_**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/008.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=86aa8cd8a7d6749f9046a5d41364320a" alt="" width="1624" height="578" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/008.png" />

8. **Note:** This IAM role will be created by default. It has a policy attached with the name [**AWSDataLifecycleManagerServiceRole**](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/service-role/AWSDataLifecycleManagerServiceRole\$serviceLevelSummary)
9. Tags: To add a tag, click on the **Add Tag** button.
10. Enter Key as ***Name*** and Value as ***Hourly***
11. Keep all the options as default and click on the **Next** button, to proceed further.
12. Schedule details:

    * Schedule name: Enter ***Hourly***
    * Frequency: Select **Custom cron expression**
    * Cron expression: Enter ***cron(1 \* \* \* ? \*)***
    * **Note:** To know more about the cron format please checkout [AWS Documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions)
    * Retention type: Select **Count**
    * Keep: Enter ***1 Snapshot***
    * Keep advance settings as default and Click on the **Review policy** button.
13. Review the policy and click on the **Create policy** button.
14. The lifecycle policy is now created.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/009.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=4c2bbee939efc73f39d678960427791e" alt="" width="2234" height="696" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/009.png" />

#### Task 4: Wait for an hour

1. Since Automated snapshots of EBS volume can be only created at a minimum duration of 1 hour. You need to wait for Volume creation of one hour, not the policy. For example, you have launched the EC2 Instance at 10:23 AM, In this case, you will be able to see the first automated EBS Snapshot at 11:23 AM.
2. This is a restriction for the Automated EBS Snapshot from AWS Side.

#### Task 5: Check the Automated snapshot

1. Make sure you are in **US East (N. Virginia) us-east-1** Region.
2. Navigate to EC2 by clicking on the **Services** menu in the top, then click on **EC2** in the **Compute** section.
3. Navigate to **Elastic Block Store** on the left panel and click on **Snapshot.**
4. There is already one snapshot present whose description shows all the details.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/010.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=54073aa53edf6b49d33a6ca84330f46a" alt="" width="1591" height="184" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/010.png" />

> #### Do you know?
>
> Keep in mind that DLM policies work on a regional basis, so you'll need to create separate policies if you have EBS volumes in different regions that require different snapshot schedules or retention periods.

#### Task 6: Validation Test

1. Once the lab steps are completed, please click on the **Check my work** button on the Right side panel.
2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
3. Sample output :

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/011.gif?s=2381a0dc987dca4f49851995bc295961" alt="" width="1000" height="619" data-path="images/labs/create-automatic-snapshot-of-ebs-volume-using-amazon-dlm/011.gif" />

#### Task 7: Deleting AWS Resources

##### 1: EC2 Instance

1. Make sure you are in **US East (N. Virginia) us-east-1** Region.
2. Navigate to EC2 by clicking on the **Services** menu at the top, then click on **EC2** in the **Compute** section.
3. Navigate to the **Instances** present on the left panel.
4. Select the Present EC2 Instance, Click on the **Instance state** present in the menu bar, and choose the **Terminate Instances** option.
5. On the pop-up menu, click on the **Terminate** button.
6. EC2 Instance will be terminated.

##### 2: DLM policy

1. Navigate to the **Lifecycle Manager** present on the left panel under the **Elastic block store**.
2. To delete the present snapshot policy perform the following tasks:

   * Select the **policy** present,
   * Click on the **Actions** present in the menu bar and,
   * Choose the **Delete lifecycle policy** option.
3. On the confirmation menu, click on the **Delete** button.
4. The policy will be deleted.

##### 3: EBS Snapshot

1. Navigate to the **Snapshots** present on the left panel under the **Elastic block store**.
2. Delete the snapshot by selecting the present snapshot, and choosing the **Delete** option present in **Actions**.
3. The snapshot will be deleted.

### Completion and conclusion

1. You have successfully created and launched Amazon EC2 Instance.
2. You have successfully created the EBS Snapshot policy using the Data lifecycle manager
3. Amazon DLM has created an Automated snapshot of EBS volume attached to EC2 Instance after one hour.
4. You have successfully deleted all the AWS Resources created during this lab.

### End lab

1. Sign out of AWS Account.
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End lab** in the IP Lab Portal and wait till the process gets completed.

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Validate EC2 Instance Type t2.micro** — Check whether the EC2 instance type is t2.micro.
* **Create EC2 Snapshot** — Check whether EC2 instance snapshot is created or not

## Related help

* [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting)
