DEV Community

Cover image for Learning AWS Day by Day — Day 31 — Case Study using EC2, EBS, EFS
Saloni Singh
Saloni Singh

Posted on

Learning AWS Day by Day — Day 31 — Case Study using EC2, EBS, EFS

Exploring AWS !!

Day 31:

Case Study — EC2, EBS, EFS

Image description

Problem Statement:
You work for XYZ Corporation. Your corporation is working on an application and they require secured web servers on Linux to launch the application.
You have been asked to:

  1. Create an Instance in us-east-1 (N. Virginia) region with Linux OS and manage the requirement of web servers of your company using AMI
  2. Replicate the instance in us-west-2 (Oregon) region
  3. Build two EBS volumes and attach them to the instance in us-east-1 (N. Virginia) region
  4. Delete one volume after detaching it and extend the size of other volume
  5. Take backup of this EBS volume

Solution:
1.Create an instance in N.Virginia with Linux OS

Image description

  1. Creating an image i.e. AMI for the instance launched in N.Virginia, go to Action → Image and Template → Create Image

Image description

  1. Create Image, by entering the required details such as Image name and description and click create

Image description

  1. The AMI is created for the instance in N.Virginia, now we need to create a copy of the same

Image description

  1. Right click and Copy AMI

Image description

  1. Select the US West Oregon and click Copy AMI

Image description

  1. The AMI copy operation is initiated, and we can check the progress in us-west-2(Oregon) as well.

Image description

  1. The progress can be checked this way in the Oregon region as well.

Image description

  1. The AMI is created and we can click on ‘Launch Instance from image’

Image description

  1. Using the AMI we were able to successfully replicate the Instance in Oregon Region

Image description

  1. Now to create EBS volumes, we need to go to Volumes and click on Create Volume → Select the exact AZ which is for the instance as well, i.e. is your instance is launched in us-east-1c then make sure that the EBS created should also be in us-east-1c, we need to create 2 such volumes.

Image description

  1. Click on Actions and choose ‘Attach’ to attach the volumes to the respective instance

Image description

  1. Select the instance and AZ accordingly

Image description

  1. The Device name appears and it can range from sdf to sdp, click on Attach Volume

Image description

  1. Now to mount the EBS volumes, Copy the IPv4 address of the instance launched

Image description

  1. We can connect to the instance even by putty

Image description

  1. We can also connect to the instance directly via Instance Connect

Image description

  1. As the instance launched is Linux, we are connected to ec2-user@ip-172–31–86–236

Image description

  1. For Linux OS, we need to run following command to get updates → sudo yum update

Image description

  1. Give following commands to mount the EBS volume on the EC2 instance
lsblk
file –s /dev/devicename
mkfs –t ext4/dev/devicename
mkdir ebsvolume
mount /dev/devicename path to ebsvolume
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

  1. To unmount the EBS volume, give following commands:
df –h
unmount /dev/devicename
Enter fullscreen mode Exit fullscreen mode

Image description

  1. As the EBS is unmounted we can detach the volume and delete it

Image description

  1. We can modify the size by clicking Actions → Modify Volume

Image description

  1. Give the desired size and click Modify

Image description

Image description

  1. Size volume modification will be in progress

Image description

  1. To create a backup of this volume, we can go to Actions → Create Snapshot

Image description

  1. Enter the required details such as description and click Create Snapshot

Image description

  1. Backup of EBS is created

Image description

Top comments (0)