High Availability Architecture using AWS CLI

High Availability Architecture using 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.

Prerequisites:-

aws configure

aws --version
No alt text provided for this image

Step 1 : CREATE A KEY PAIR

This key will be further used to log into the instance.

aws ec2 create-key-pair --key-name ha_aws > ha_aws.pem
No alt text provided for this image

STEP 2 - CREATING A SECURITY GROUP

This sg will act as a firewall for the instance.

aws ec2 create-security-group --group-name ha_aws_sg --description 
"ha_aws_sg" > ha_aws_sg.txt
No alt text provided for this image
No alt text provided for this image

STEP 3 - LAUNCHING AN INSTANCE

Using all the above resources now.

aws ec2 run-instances --image-id ami-08e0ca9924195beba  --instance-type t2.micro --count 1 --subnet-id subnet-78253910 --security-group-ids sg-01598c0892a138b3b  --key-name ha_aws
No alt text provided for this image
No alt text provided for this image

STEP 4 - CREATING AN EBS VOLUME

Create the EBS volume of 1 GB which will act as an external hard disk for the instance.

aws ec2 create-volume --volume-type gp2  --size 1 --availability-zone ap-south-1a  > ha_aws_ebs.txt
No alt text provided for this image
No alt text provided for this image

STEP 5 - ATTACHING THE EBS VOLUME TO THE INSTANCE

Attaching the above created EBS volume with the instance.

aws ec2 attach-volume --instance-id i-0bc7307965b2dfc7e  --volume-id vol-05a4403f05e8cea3b  --device /dev/sdf
No alt text provided for this image
No alt text provided for this image

STEP 6 - CREATING PARTITION OF EBS VOLUME AND MOUNTING

After logging into the instance using the key we created.

fdisk -l
No alt text provided for this image

Format the partition

mkfs.ext4  /dev/xvdf
No alt text provided for this image

Before mounting , install apache webserver

yum install httpd -y
No alt text provided for this image

Now mount the partition to the folder /var/www/html and then check

mount /dev/xvdf /var/www/html
df -h
lsblk
No alt text provided for this image

STEP 7 - CREATING S3 BUCKET AND ADDING IMAGE IN S3 BUCKET

aws s3 mb s3://ha-aws-s3
No alt text provided for this image
No alt text provided for this image

Now add the image into the s3 bucket

aws s3 cp  .   s3://ha-aws-s3  --recursive --acl  public-read
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

STEP 8 - CREATING THE CONTENT DELIVERY NETWORK - CDN

aws cloudfront create-distribution  --origin-domain-name   ha-aws-s3.s3.amazonaws.com
No alt text provided for this image
No alt text provided for this image

STEP 9 - DEPLOYING WEBAPP USING THE CLOUDFRONT URL

Now replace the previous url with the cloudfront url

No alt text provided for this image
No alt text provided for this image

So finally, here the data is being extracted from the s3 bucket but with the help of Cloudfront which leads to low latency and more efficiency.

THANK YOU

Toshine Garg

UTS Australia | Chandigarh University | Pianist

4 年

Nice work ?? Sujagi Verma

要查看或添加评论,请登录

Sujagi Verma的更多文章

社区洞察

其他会员也浏览了