Learning AWS Day by Day — Day 31 — Case Study using EC2, EBS, EFS
Tags: aws, cloud, cloudcomputing, beginners
Published: 2024-04-08 17:13:00

Exploring AWS !!

**Day 31:**

**Case Study — EC2, EBS, EFS**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1aohgnt4g2dzd50cu9e.png)



**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/la3qemqi4xiixwo6mmmt.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6iy5jzjrhtlil0hwt00.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8i4fh18kyuinqximdhf9.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1yqtlqcmd86etvpscdou.png)




5. Right click and Copy AMI

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4h1dbss6iawofjrj6viq.png)



6. Select the US West Oregon and click Copy AMI

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pj52fps4x49m06srznvx.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9unlaufcmwttf9pyhjod.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/51kmrcclsrg8pqkcrqpc.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u0tneuyzsz6s3ecyfli5.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5qsq6z7q1tue41u6zao.png)



11. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3niw95zye0g5y37way4.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/74i5kugsw1mp6ihrmqwv.png)



13. Select the instance and AZ accordingly

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psjuf59m3pl7690wap81.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yndpaltfpt2ski1rivi.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xx5yntnm4whoor2izgrb.png)



16. We can connect to the instance even by putty

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q62sz6lvf5ck84039fpx.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92jss9q7pdfj0yg4d8f1.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xg1amc71boixph57obcj.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mvltjdq2to2f7690w4tz.png)



20. 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
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3bsoggknlht2i0nt626s.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/absazscmdra4bonwtlya.png)




21. To unmount the EBS volume, give following commands:

```
df –h
unmount /dev/devicename
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4rizjnr1knn9jcqduwp.png)


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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uq5rxmpui5jsgo66luko.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nu0o200a9as0e3eq178v.png)



24. Give the desired size and click Modify

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/autonalobcptlqlxeh1w.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9zdjzaz82taiaonefvx.png)





25. Size volume modification will be in progress

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ioj1oqxzmxislv9nz5gn.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k32xdcaize8iyy4n01lz.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zpywrnj4fsuz4hjwzkiw.png)



28. Backup of EBS is created

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aipf0zm6joxve449n8bg.png)