High Availability Architecture with AWS CLI…..

Tejashwinikottha
4 min readNov 12, 2020

Main Objective :

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

Before Knowing About How to Setup ….know few things about CloudFront!!

What is AWS CloudFront ?🤔

Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment.

What is AWS CloudFront use and Who uses this

Amazon CloudFront is a web service that speeds up distribution of your static and dynamic web content, such as . html, . css, . js, and image files, to your users.

For Example , Amazon Prime Video uses Amazon CloudFront to deliver solid streaming experience to more than 18 million football fans.

Now Let’s see How to setup this…!!!

For this we need to create an High Availability Architecture with AWS CLI which includes these Steps 👇👇👇

STEP-1: Webserver configured on EC2 Instance

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

STEP-3:Static objects used in code such as pictures stored in S3

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

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

Implementing These Steps 🙄👇👇

STEP-1: Webserver configured on EC2 Instance

To Configure the Webserver through AWS CLI ,

First ,we need to configure our AWS CLI in cmd prompt , For this just go through this blog👇 Which includes how to configure AWS CLI and How to create an EBS volume in AWS using AWS CLI 😍

To configure Webserver ,

Install httpd in Instance by using command

→>>>yum install httpd -y

By using this we can configure configure webserver.

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

I attached an EBS volume to Instance andit it is partitioned ,formated and mounted it to the (mount point) folder —-/var/www/html —

Commands used for

Formatting — ->>>mkfs.ext4 <partition drive>

Mounting — — >>>mount <partition drive> <mountpoint>

In this way Document root(/var/www/html) made persistent

STEP-3:Static objects used in code such as pictures stored in S3

Create an S3 bucket using cmd prompt…,

Here I created a bucket named “httpd server” in the region “ap-south-1"

Check whether this bucket created or not in WebUI

Now upload an image in this bucket (httpd server bucket).

Also given public access to this uploaded image

When we upload an image in bucket ,then an Object URL creates in S3

Now use this URL in code of a html file to run it in webserver.

Here I used my image- object URL in this server.html file

Now access this file through web (chrome ) by using Ip and file name as

_____<Instance public_ip >/<file>________

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

To set up CDN using Cloudfront we used origin name as s3 bucket and given root object as above uploaded image.

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

When we setup the CDN , then it creates a domain name(URL) by which we can access the root object at anywhere.

Now ,Lets see how this new domain_name works in webapp

Use _____<domain_name>/<object>____ in chrome

Finally ,we used the cloudfront URL in webapp and accessed the image .

This is how we used Cloudfront service inluding S3 service.

--

--