High Availability Architecture with AWS Command Line Interface(CLI)

High Availability Architecture with AWS Command Line Interface(CLI)

ARTH Task-6

Task Description

  • 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 Content Delivery Network using CloudFront and using the origin domain as S3 bucket. 
  • Finally place the Cloud Front URL on the webapp code for security and low latency.
  1. Install HTTPD over Redhat OS. The command for installing the OS goes as follows:
yum install httpd

After successful installation of the HTTPD, Start the httpd services and check the working status of the server. The command for the same goes as follows:

systemctl start httpd
systemctl status httpd

Following is the output of all the above commands:

No alt text provided for this image


  • Configure the AWS-CLI by using the command with the output attached as below:
aws configure
No alt text provided for this image

2. Document Root(/var/www/html) made persistent by mounting on EBS Block Device.

The next step is to attach an EBS Volume to the /var/www/html folder to make the data persistent.We can use the below command to create an EBS Volume of 1GiB

aws ec2 create-volume --availability-zone --size --volume-type gp2
No alt text provided for this image

Now we can attach the above created EBS volume to the desired instance using the below command and the CLI and GUI outlook is as belows:

aws ec2 attach-volume --device sdb -- instance-id instance id --volume-id volume-id
No alt text provided for this image
No alt text provided for this image

In order to check if the volume is attached or not we can we can use the below command

fdisk -l

The output of the command is as follows:

No alt text provided for this image

Now we can use the following command to get inside the /dev/xvdb directory.The command is as follows with the desired output below:

fdisk /dev/xvdb
No alt text provided for this image

Now that we are in the desired directory we can create a new partition.We can press "n" to create a new partition and "p" for primary partition.The output is as below:

No alt text provided for this image

Now we have to format the partition using the below command

mkfs.ext4 /dev/xvdb1

The output of will be seen as follows:

No alt text provided for this image

Now we have to mount the partition to the /var/www/html folder and in order to check the attached disk we can use the below commands to which the output will be as follows:

mount /dev/xvdb1 /var/www/html

df -h
No alt text provided for this image

3.Static objects used in code such as pictures stored in S3

Now we have to use the AWS CLI to create a S3 bucket the command for the same goes as follows:

aws s3 mb s3://bucketname --region
No alt text provided for this image
No alt text provided for this image

Now we can upload the desired data to the bucket and set the permissions to public

aws s3 cp (location) (name of object) s3://(bucketname)/imagename.png --acl public-read
No alt text provided for this image
No alt text provided for this image

4.Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.

Now we have to create a distribution in cloud front to distribute the data to all Edge Locations of AWS by using the below command and the below is the output:

aws cloudfront create-distribution --origin-domain-name bucketname.s3.amazonaws.com
No alt text provided for this image
No alt text provided for this image

5.Finally place the Cloud Front URL on the webapp code for security and low latency.

The last step is to create a HTML code and specify the cloudfront url in the image tag.The HTML code goes as follow:

No alt text provided for this image

Now check the final results by using the following

http://IP/FileNamw.html

The final result are as follows

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


To view or add a comment, sign in

More articles by Shreya Labhsetwar

  • Increase-Decrease Size of Static Partitions

    ARTH Task-7.1[B] Increase or Decrease the size of Static Partition in linux Step 1- Add a Hard disk of any size We will…

  • Integration of LVM with HADOOP

    ARTH TASK-7.1 [A]- Integrating LVM with Hadoop and providing Elasticity to Datanode Storage What is LVM? LVM is a tool…

  • AWS Command Line Interface

    ARTH TASK-3 Task Description- 1) Create a key Pair. 2) Create a security group.

Others also viewed

Explore content categories