??Create High Availability Architecture with AWS CLI??

??Create High Availability Architecture with AWS CLI??

>>>Task Description

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

In this practical I'm going to use AWS CLI, IAM, EC2, EBS, S3 and CloudFront service of AWS. We're going to do the complete practical using CLI not GUI, which makes the task more interesting.

Lets start with first part of task which further divided into many small sub-task .

1. Webserver configured on EC2 Instance

1.1 Starting the instance

No alt text provided for this image

we can also verify it by using GUI

No alt text provided for this image

1.2 Install the httpd software :

For configuring the web server we have to first install the httpd software with the help of yum and then we have to start the service of it .

#command used
No alt text provided for this image
No alt text provided for this image
1-Command to install httpd server:-
yum install httpd

2-Command to start the service :-
systemctl start httpd 
         (or)
systemctl enable httpd

3-Command to check the service is start or not :-
systemctl status httpd 

also,we have to configure security group of respective instances to fully configure web-server.

Here we can see that the status is in active (running) . Hence the configuration of web server is done successfully.

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

2.1 Creating a EBS volume & Attaching this EBS volume to the instance:

No alt text provided for this image

Other than GUI ,You can also cross-check using in your linux instance using command >>> "fdisk -l " as shown below:

No alt text provided for this image


2.2 create, format & mount partition :

  • Creating a partition:
No alt text provided for this image
Commands used above:-
fdisk /dev/xvdf : this is for creating the partition
n is for new partition
p is for primary partition
just enter three times and it will create a new partition for you
w is for saving
lsblk can let you know whether the partition has been created or not ,You can see below a partition has been created in the xvdf volume i.e xvdf1

No alt text provided for this image
  • Formatting the partition :
No alt text provided for this image
Command to format:-
mkfs.ext4 /dev/xvdf1
  • Mounting that Partition:
No alt text provided for this image
No alt text provided for this image

using command "df -h" , we can check our partition is mounted successfully as shown above.

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

For putting the static objects in S3 which used in code we have to first create the bucket and then we have to upload that object to it . Command to create the bucket is to given below. In my case the bucket name is "webst1".

Command to create s3 :-
  aws s3api create-bucket --bucket webst1  --region ap-south-1  --acl public-read --create-bucket-configuration LocationConstraint=ap-south-1


No alt text provided for this image

Here we can see that that the bucket is created successfully , Now we can verify it through Web UI.

No alt text provided for this image

now, we are going to put the object in it . So for that we have to mention the source path and the destination path. For source path we have to mention the location where the object is stored and for the destination write the bucket name . Command is given below :

No alt text provided for this image

Now we are going to verify it through web that is is uploaded or not .

No alt text provided for this image

Here we can see that the object is uploaded successfully . But we have to be sure that the bucket and the object is publically accessible .

No alt text provided for this image

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

Firstly create the cloud front distribution for S3 bucket objects, In my case the origin-domain-name is :- "webst1.s3.amazonaws.com " and the command is given below :

Command :-
aws cloudfront create-distribution --origin-domain-name webst1.s3.amazonaws.com --default-root-object imtest.png
No alt text provided for this image

Above highlighted url is going to be used in our html code which we deploy over webserver.

Here the Cloud Front is successfully created but we are going to check it through Web UI.

No alt text provided for this image


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

Now we have to finally place the Cloud front URL on web app code for security and low latency .This file is created inside /var/www/html directory:

No alt text provided for this image

Now client can easily access the services from the server by using server public IP. (syntax>> https://ip/name of the file)

Now you can see the final output:

No alt text provided for this image

Now Our webpage becomes faster in terms of speed ,more secure and reliable.

??Here , the given task is successfully completed .....??

??THANK YOU... AND KEEP LEARNING??



要查看或添加评论,请登录

Abhinav Singh的更多文章

社区洞察

其他会员也浏览了