Task 2: Create High Availability Architecture with AWS CLI

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

No alt text provided for this image
No alt text provided for this image

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

No alt text provided for this image
No alt text provided for this image

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

No alt text provided for this image
No alt text provided for this image

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.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Let's install apache web-server httpd and mount our 1GB EBS vol. to Document root(/var/www/html).

Command: yum install httpd

No alt text provided for this image

Now, let's mount the 1GB volume.

No alt text provided for this image

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

No alt text provided for this image
No alt text provided for this image

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

No alt text provided for this image
No alt text provided for this image

Now, let's create a demo web page in Document root and add the object URL of this image and use it.

No alt text provided for this image

In the below image we can see that our web server is working fine and our demo site is available.

No alt text provided for this image

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

No alt text provided for this image
No alt text provided for this image

Finally, now we need to add this CloudFront URL to our demo page and we have done with the task.

No alt text provided for this image
No alt text provided for this image

Now we have done with Task 2 of AWS CLI.

Done!!!!!!


To view or add a comment, sign in

More articles by Dikshant Mali

  • LW Terraform Task 5: Configure Apache Webserver On EC2 And VPC on AWS

    ✍️ Write terraform code to configure the following things on AWS - 📍Launch One VPC in north verginia having name as…

  • LW Terraform Task 2: Configure EC2 And Attach EBS Volume Of 1GB

    ✍ Create a key pair ✍ Create a security group ✍ Launch an instance using the above created key pair and security group.…

  • AWS CSA TASK 3

    ✍ Create an AWS EC2 instance ✍ Configure the instance with Apache Webserver. ✍ Download PHP application name…

  • Task : AWS CSA And DEVELOPER Track

    AWS Task 1 : Perform Below Operation with AWS CLI 🔅 Create a key pair 🔅 Create a security group 🔅 Launch an instance…

    1 Comment

Explore content categories