Task 2: Create High Availability Architecture with AWS CLI
AWS CSA And Developer Track
✳️Create High Availability Architecture with AWS CLI
✳️The architecture includes-
⭕ Webserver configured on EC2 Instance
⭕Document Root(/var/www/html) made persistent by mounting on EBS Block Device.
⭕Static objects used in code such as pictures stored in S3
⭕Setting up the Content Delivery Network using CloudFront and using the origin domain as an S3 bucket.
⭕Finally, place the Cloud Front URL on the web app code for security and low latency.
Let's perform each of the operations one by one.
Process 1: Webserver configured on EC2 Instance
Let's launch an EC2 instance.
Command: aws ec2 run-instances --image ami-0947d2ba12ee1ff75 --instance-type t2.micro --count 1 --key-name lwaws2020 --security-group-ids sg-0cd3e6f9ded17ca55
We have successfully launched the ec2 instance and it is in running state. The AMI that I have used is Amazon Linux 2 Ami and I have launched it is N.Virginia(us-east-1e).
Process 2: Document Root(/var/www/html) made persistent by mounting on EBS Block Device
Let's create an EBS volume of size 1 GB in the same region (us-east-1e) so that we can later on use it.
Command: aws ec2 create-volume --availability-zone us-east-1e --size 1
Let's attach this volume to the ec2-instance.
Command : aws ec2 attach-volume --volume-id vol-0a7e3cd49e481f794 --instance-id i-07bf58c9e6e5c3beb --device /dev/sdb
In the image, we can check the status of our 1GB EBS volume is in-use. which means we have successfully attached it to our instance.
Now, Let's partition and format this 1GB device for use.
Let's install apache web-server httpd and mount our 1GB EBS vol. to Document root(/var/www/html).
Command: yum install httpd
Now, let's mount the 1GB volume.
Process 3: Static objects used in code such as pictures stored in S3
Create and launch a bucket in s3
Command: aws s3 mb s3://mysite-bucket
Now Let's upload an image to this s3 bucket. This image we will use to for the basic web page we create.
Command: aws s3 cp --acl public-read C:\Users\diksh\OneDrive\Desktop\header1.jpg s3://mysite-bucket
Now, let's create a demo web page in Document root and add the object URL of this image and use it.
In the below image we can see that our web server is working fine and our demo site is available.
Process: Setting up the Content Delivery Network using CloudFront and using the origin domain as an S3 bucket
Let's make a cloud front distribution with our s3 bucket mysite-bucket.
Command: aws cloudfront create-distribution --origin-domain-name mysite-bucket.s3.us-east-1.amazonaws.com
Finally, now we need to add this CloudFront URL to our demo page and we have done with the task.
Now we have done with Task 2 of AWS CLI.
Done!!!!!!