Exploring AWS !!
Day 31:
Case Study — EC2, EBS, EFS
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
2. Creating an image i.e. AMI for the instance launched in N.Virginia, go to Action → Image and Template → Create Image
3. Create Image, by entering the required details such as Image name and description and click create
4. The AMI is created for the instance in N.Virginia, now we need to create a copy of the same
5. Right click and Copy AMI
6. Select the US West Oregon and click Copy AMI
7. The AMI copy operation is initiated, and we can check the progress in us-west-2(Oregon) as well.
8. The progress can be checked this way in the Oregon region as well.
9. The AMI is created and we can click on ‘Launch Instance from image’
10. Using the AMI we were able to successfully replicate the Instance in Oregon Region
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.
12. Click on Actions and choose ‘Attach’ to attach the volumes to the respective instance
13. Select the instance and AZ accordingly
14. The Device name appears and it can range from sdf to sdp, click on Attach Volume
15. Now to mount the EBS volumes, Copy the IPv4 address of the instance launched
16. We can connect to the instance even by putty
17. We can also connect to the instance directly via Instance Connect
18. As the instance launched is Linux, we are connected to ec2-user@ip-172–31–86–236
19. For Linux OS, we need to run following command to get updates → sudo yum update
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
21. To unmount the EBS volume, give following commands:
df –h
unmount /dev/devicename
22. As the EBS is unmounted we can detach the volume and delete it
23. We can modify the size by clicking Actions → Modify Volume
24. Give the desired size and click Modify
25. Size volume modification will be in progress
26. To create a backup of this volume, we can go to Actions → Create Snapshot
27. Enter the required details such as description and click Create Snapshot
28. Backup of EBS is created