>_ Create High Availability Architecture using AWS CLI by Intregrating Apache Web Server, EBS, S3 & CloudFront >_

What is AWS ?

Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 175 fully featured services from data centers globally. Millions of customers — including the fastest-growing startups, largest enterprises, and leading government agencies — are using AWS to lower costs, become more agile, and innovate faster.

What is AWS CLI ?

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

What is EBS ?

Amazon Elastic Block Store (EBS) is an easy to use, high performance block storage service designed for use with Amazon Elastic Compute Cloud (EC2) for both throughput and transaction intensive workloads at any scale.

What is S3 ?

Object storage built to store and retrieve any amount of data from anywhere. Get started with Amazon S3. Request more information. Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.

What is ClouFront ?

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.

So lets begin this task !!

OUTLINES

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

PRE-REQUISITES

> AWS ACCOUNT

> AWS CLI Installed

STEP 1 — CREATING AN EC2 INSTANCE

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment.

The key pair used has already been created

The security group has also been created and is made to allow port 22 and port 80 for ssh connection and allowing http connectivity.

The EC2 Instance can be created by using these the shown key-pair and the security group by using the CLI

After running the command the EC2 Instance is created and can be seen

STEP 2 — CREATING AN EBS VOLUME

An Amazon EBS volume is a durable, block-level storage device that can be attached to the EC2 instances. EBS volumes are flexible. For current-generation volumes attached to current-generation instance types, you can dynamically increase size, modify the provisioned IOPS capacity, and change volume type on live production volumes.

The EBS volume can be created from the command line

After running the command EBS Volume of 1GB is created and can be seen as

The 1GB EBS Volume shows its ‘State’ as Available as it is not yet attached to any of the instances.

STEP 3 — ATTACHING THE EBS VOLUME

After you attach a volume to an instance, you can use it as you would use a physical hard drive.

The EBS volume created can be attached to the Instance by using the command

After Attaching the volume to the EC2 Instance the 1GB EBS volume shows its ‘State’ as ‘in use’.

STEP 4 — ESTABLISHING SSH CONNECTION WITH THE INSTANCE TO CONNECT THE WEBSERVER AND MAKE A FOLDER PERSISTENT

For configuring the Web Server and running some commands you need to establish a ssh connection to the Instance.

This can be done by running the command

STEP 5 CONFIGURING THE WEB-SERVER ON THE INSTANCE

After establishing a connection to the instance the web server can be configured

STEP 6 — MAKING DOCUMENT ROOT PERSISTENT BY MOUNTING THE EBS VOLUME

EBS Volume can be mounted on /var/www/html folder by the following steps

Creating a partition

Mounting the partition

The content of the volume can be seen

A partition in the volume can be created

Mounting of the volume to the folder can be done

STEP 7 — CREATING S3 BUCKET

An Amazon S3 bucket is a public cloud storage resource available in Amazon Web Services’ (AWS) Simple Storage Service (S3), an object storage offering. Amazon S3 buckets, which are similar to file folders, store objects, which consist of data , images etc.

An S3 Bucket can be created from the command line

After running the command the S3 bucket created can be seen

STEP 8 — UPLOADING IMAGE TO THE S3 BUCKET

Static objects can be uploaded to S3 and can be made accessible by the public. This can be done using CLI as

The uploaded image can be seen

STEP 9 — CREATING A 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.

A CloudFront can be created using the CLI and the created S3 bucket as

After running the command CloudFront is created and can be seen as

STEP 10 — CONNECTING TO THE EC2 INSTANCE AGAIN BY SSH TO DEPLOY THE WEBPAGE CONTAINING THE CLOUDFRONT URL

To provide security and low latency to the WebPage CloudFront URL is used in the Code. The CloudFront URL can be used in the WebPage code by again connecting the EC2 instance by ssh. This can be done as

The Code for the Webpage to be deployed can be written as

Finally the deployed WebPage taking an Image from the CloudFront URL can be seen

CONCLUSION

A high availability architecture which is providing security and low Latency in a Company’s WebSite can be deployed by using AWS CloudFront. By using the CloudFront services the company would be free from such issues.

If you find it interesting please upvote it.

Connect with me on LinkedIn | GitHub

Lifelong learning technologies

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store