Creating High Availability Architecture with AWS CLI

Lalita Sharma
6 min readNov 2, 2020

--

→ AWS EC2 INSTANCE|WEBSERVER|EBS|S3|CLOUDFRONT ←

High Availability Architecture

Let’s learn some basics about the AWS High Availability architecture:-

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?

AWS-CLI(Amazon web services-Command line interface) is an open-source tool that enables you to interact with AWS services using commands through our command prompt in command line. This AWS-CLI provides the same functionality as WEB-UI based on AWS management console.

What is WEBSERVER?

A Web-Server delivers content for a website to a client that requests it, like a web browser. A web server communicates with a web browser using HTTP. The main job of a web server is to display website content through storing, processing and delivering webpages to users.

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. A broad range of workloads, such as relational and non-relational databases, enterprise applications, containerized applications, big data analytics engines, file systems, and media workflows are widely deployed on Amazon EBS.

What is S3?

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. This means customers of all sizes and industries can use it to store and protect any amount of data for a range of use cases, such as data lakes, websites, mobile applications, backup and restore, archive, enterprise applications, IoT devices, and big data analytics. Amazon S3 provides easy-to-use management features so you can organize your data and configure finely-tuned access controls to meet your specific business, organizational, and compliance requirements. Amazon S3 is designed for 99.999999999% (11 9’s) of durability, and stores data for millions of applications for companies all around the world.

What is 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. CloudFront is integrated with AWS — both physical locations that are directly connected to the AWS global infrastructure, as well as other AWS services. If you use AWS origins such as Amazon S3, Amazon EC2 or Elastic Load Balancing, you don’t pay for any data transferred between these services and CloudFront. Amazon’s CDN offers a simple, pay-as-you-go pricing model with no upfront fees.

****************************************************************

Task Description📄

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

****************************************************************

Step-1: Create a key-pair

key-pair created using CLI
WEBUI

Step-2: Create a security group

security group created using CLI
WEBUI

Step-3: Create an INBOUND rule

command to allow Inbound rule for SSH protocol
WEBUI

REMEMBER: Create a VPC security group for a public web server. Make sure that the security group that you choose includes inbound rules for Secure Shell (SSH) and HTTP access.

Step-4: Create an EC2 instance

Instance launched using CLI
WEBUI

Step-5: Create an EBS volume of size 1GiB

Ebs volume created using CLI
WEBUI

Step-6: Attach EBS volume created above to the previous launched instance

volume attached using CLI
WEBUI

Step-7: Check Volume attached to the EC2 instance

Using command:- # fdisk -l

size: 1 GiB

Step-8: Create the partition of size 1023 MB of volume attached

Using command:- # fdisk /dev/xvdf

partition created

Step-9: Format the partition

Using command:- # mkfs.ext4 /dev/xvdf

partition formatted

Step-9: Mount the partition to the Document root(/var/www/html)

Using command:- #mount /dev/xvdf /var/www/html/

partition mounted successfully

Step-10: Check the mount partition

Using command:- # df -h

storage : 976 MB

Step-11: Install ‘httpd’ package to set-up WebServer

Install software using command:- # yum install httpd

s/w installed

After installing ‘httpd’ software, start the service ,using command:-

# systemctl start httpd

# systemctl status httpd

webserver activated

Step-12: Create a html file to the /var/www/html folder

Html file created using command:- # vi <file-name>.html

‘ls’ command is used to list the files created

Step-13: Create a S3 Bucket

S3 bucket created using CLI
WEBUI

Step-14: Upload the local file(or image) to the S3 bucket

image uploaded using CLI
WEBUI

Step-15: Change object permission to public read in S3

CLI

Step-16: S3 object URL

object URL

Step-17: Open this object URL to the browser

s3 object url

Step-18: Write some html code and put this S3 Object url in ‘webscli.html’ file

S3 object url mention to the webserver

Step-19: Open the html file — ‘webscli.html’ to the Browser

ip-address/webscli.html

Step-20: Create CloudFront distribution using Origin as S3 object URL

CloudFront distribution created using CLI
WEBUI

Step-21: Open the CloudFront URL to the Browser

CloudFront URL

Step-22: Place the CloudFront URL into the webserver

Here, Mention this CF Url in the html code in ‘webscli.html’ file into our webserver for low latency and making cache at near-by edge location.

webscli.html

Step-23: Run the html file in the Browser

ip-address/webscli.html

Thus, In the WebApp, the static file(or image) comes from CloudFront Service origin as S3 object url and storage(or html code) is of EBS Volume (persistent) and the WebServer is running on EC2 instance.

Hence, TASK-COMPLETED successfully!

THANK YOU(*-*)

--

--

Lalita Sharma
Lalita Sharma

Written by Lalita Sharma

Aeromodeller|Passionate|Technoholic|Learner|Technical writer

No responses yet