Skip to main content
Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console. Open IP Lab Portal

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

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

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.
You can only start one lab at any given time

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
  1. For Amazon Machine Image (AMI): Search for Amazon Linux 2023 kernel-6.1 AMI in the search box and click on the Select button.
  2. For Instance Type: select t2.micro
  1. For Key pair: Select Create a new key pair Button
    • Key pair name: MyEC2Key
    • Key pair type: RSA
    • Private key file format: .pem
  2. Select Create key pair Button.
  3. 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
  4. SSH rule will be selected by default
  5. Keep the Rest thing Default and Click on Launch Instance Button.
  6. Select View all Instances to View the Instance You Created
  7. 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.
  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_
  1. Note: This IAM role will be created by default. It has a policy attached with the name AWSDataLifecycleManagerServiceRole
  2. Tags: To add a tag, click on the Add Tag button.
  3. Enter Key as Name and Value as Hourly
  4. Keep all the options as default and click on the Next button, to proceed further.
  5. 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
    • Retention type: Select Count
    • Keep: Enter 1 Snapshot
    • Keep advance settings as default and Click on the Review policy button.
  6. Review the policy and click on the Create policy button.
  7. The lifecycle policy is now created.

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.

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 :

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