High Availability Architecture Using AWS CLI:

Ashutosh Kulkarni
4 min readMar 20, 2021

Task 6:

In this task we are going to perform following operations:

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

Launch EC2 Instance:

This is Elastic compute service provided by aws cloud.

We need to run following command to launch a instance:

# aws ec2 run-instances

— image-id

— instance-type

— key-name

— count

— security-group-ids

Now, we need to check the ip and other configurations of the instance. So we have to run the following command:

# aws ec2 describe-instances — instance-ids

Now, we are logging into the instance that we’ve created. To do so we can do remote login using putty by providing key.

Configuring Apache Webserver:

So, to create a website we need to configure the webserver.

  1. install httpd software.
  2. Add index.html page to /var/www/html root directory.
  3. Start the web service.

EBS volume:

Now, we are going to attach the new EBS volume to the instance:

And making the Document Root(/var/www/html)
persistent by mounting on EBS Block Device.

For that we need to perform following steps:

  1. Create a EBS volume.
  2. Attach the volume to required instance.
  3. Create the partition of the volume.
  4. Fromat the volume using mkfs format.
  5. Mount the volume to document root(/var/www/html)
  6. Also make the mount permanent by writing in /root/.bashrc file.

Commands to do so:

S3 Bucket creation:

We are using CLI for creation of bucket. we need to run the following command to do so:

# aws s3 mb s3://task6

To store the static object i.e. image(in my case) we need to perform following command :

We can list the contents of the s3 bucket by using previous command.

Create content delivery network by using CloudFront:

For setting up Content Delivery Network using
CloudFront we are using using the origin domain as S3 bucket.

This is how we can create cloudfront distribution.

Here we have used CloudFront Distribution for security and low latency. If a client first time hits the webserver, CDN(Content Delivery Network) stores the cache of that file in the nearest edge location of the client so that when other clients hits the server from same location they will get low latency to load the page.

After that go back to /var/www/html & create a simple web app. Add domain-name of distribution in code for security and low latency.

Now, we can open our web page by using public ip address of the instance:

Task completed.

--

--