High Availability Architecture with AWS CLIv2

Prerequisite:

Problem Statement:

Step-1) Install AWS CLI and configure it.

aws --version
AWS CLI Installed
aws configure

Step-2)Create a key pair

aws ec2 create-key-pair --key-name KEY_NAME > OUTPUT.pem

Output:

key

Step-3)Create a security group

aws ec2 create-security-group --group-name GROUP_NAME --description "DESCRIPTION" > OUTPUT.TXT

Output:

Security group

Step-4)Launch an instance using the above created key pair and security group.

aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --subnet-id subnet-1105675d --security-group-ids sg-040c982abe9bb3d48 --key-name key2 > ec2inf.txt

Output

ec2 launced

Step-5)Create an EBS volume of 1 GB.

aws ec2 create-volume  --volume-type TYPE--size 1 --availability-zone ZONE_YOU_WANT > OUPTUT.TXT

Output

Step-6)Attach the above created EBS volume to the instance you created in the previous steps.

aws ec2 attach-volume  --instance-id YOUR_INSTANCE_ID --volume-id VOL_ID --device /dev/sdf

Output

EBS Attached

Step-7)Create partition , format it and mount on /var/www/html

fdisk -l
EBS attached
fdisk /dev/xvdf
making partition + formatting
mkfs.ext4 /dev/xvdf
mount /dev/xvdf /varw/www/html

Output:

mounted on /var/www/html

Step-7)Create an S3 bucket for static content

aws s3 mb s3://bucketname

Output:

S3 bucket created

Step-8) Upload content in the S3 bucket

aws s3 cp . s3://BUCKET_NAME --recursive --acl public-read

Step-9) Setting up Content Delivery Network using CloudFront and using the origin domain as an S3 bucket.

aws cloudfront create-distribution --origin-domain-name BUCKET_NAME.s3.amazonaws.com

Output

Cloudfront
Domain Name Cloudfront

Step-10) Place the Cloud Front URL on the web app code for security and low latency.

Web Code

Final Output of Website

Nothing is impossible