đź”° Create High Availability Architecture with AWS CLI đź”°

Vivekkumarrullay
3 min readNov 7, 2020

TASK DESCRIPTION :-

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 Cloud Front and using the origin domain as S3 bucket.

Finally place the Cloud Front URL on the webapp code for security and low latency.

LETS START

“First we have to launch a instance in cli”

CLI

aws ec2 run-instances — image-id ami-052c08d70def0ac62 — instance-type t2.micro — count 1 — subnet-id subnet-687c0724 — security-group-ids sg-083de04c7bd112262 — key-name mytestingkey

INSTANCE SUCCESSFULLY LAUNCH IF YOU CHECK THE WEB UI YOU OPEN AWS SERVICE AND CHECK INSTANCE LAUNCHED.

WEBUI

“Creating an EBS Volume and attaching the EBS Volume”

Now We creating an external EBS Volume so we can store or save our data in permanent storage.

CLI

Create one more EBS Volume of 1GB in AWS using CLI we use the command.

Now, we see that we have successfully created volume of 1 GB

WEBUI

Now, we are going to attach the EBS Volume.

CLI

We want to attach our EBS Volume to this EC2 Instance using CLI . I’ll show you

aws ec2 attach-volume — volume-id vol-01a0de1347dba3e07 — instance-id i-0daa340e8f58f836e — device /dev/sdf

And successfully volume attached in EC2 instance then i’ll show you very fast .

WEBUI

“Configure the Web Server in the instance”

For format, we use → mkfs.etx4 /dev/xvdf command.

CLI

First create the partition.

Attaching the external EBS Volume to the web-server document root i.e., /var/www/html

Create a partition of 1GB and will mount it to the document root “/var/www/html”.

Lets Go

MOUNT >> /dev/xvdf1 /var/www/html

Now we create a S3 bucket.

aws s3api create-bucket — bucket cloudfrontnewone — region ap-south-1 — create-bucket-configuration LocationConstraint=ap-south-1

CLI

WEBUI

Now, we can proceed with CloudFront creation.

CLI

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

WEBUI

FINALLY COMPLETED TASK AS WELL AS BLOG…..

STAY TUNED !!!!

--

--