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 web app code for security and low latency.
So Let's understand the basic terms:
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.
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.
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.
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.
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.
Step1: Webserver configured on EC2 instance
aws ec2 help

aws ec2 run-instances — image-id ami-010aff33ed5991201 — instance-type t2.micro — count=1 — subnet-id subnet-381f6574 — security-group-ids sg-0e0578030b5a1310 — key-name RHkey


Start the HTTPD services

install httpd service
yum install httpd
systemctl start httpd
Step2: Creating EBS volume and attaching it to /var/www/html
aws ec2 create-volume — availability-zone ap-south-1b — size 1


aws ec2 attach-volume — volume-id vol-01a2b7da7a7bf8bc7 — instance-id i-014f643d7a94d773f— device=/dev/sdf


Create Partition
fdisk /dev/xvdf


Formating partition
mkfs.ext4 /dev/xvdf1

Mount this storage (/dev/xvdf1) to var/www/html file
mount /dev/xvdf1 /var/www/html

Step3: Creating S3 bucket to store static object
aws s3api create-bucket — bucket srish— region ap-south-1 — create-bucket-configuration LocationConstraint-ap-south-1


Step4: Creating CloudFront
aws cloudfront create-distribution — origin-domain-name srish.s3.amazonaws.com


Step5: Place the Cloud Front URL on the
webapp code for security and low latency


Thank you!