High Availability Architecture of a Web Server using EBS, S3 & CloudFront on AWS

✔️ Prerequisites:

Before doing this practical you should know some basics of AWS CLI. You should know how to launch EC2 instance, EBS volume, and S3 using AWS CLI. You can refer to my blog on AWS CLI 👇 👇

Now let’s move to the practical. ❗️❗️

So first, we need to launch one ec2 instance on AWS using CLI. So let do this with the command.

aws ec2 run-instances

— image-id ami-038f1ca1bd58a5790

— count 1

— instance-type t2.micro

— key-name mykey

— security-group-ids sg-a5a4c183

— subnet-id subnet-7707d411

— tag-specifications=ResourceType=instance,Tags=[{Key=Name,Value=instance1}]

Here “aws ec2 run-instances” is a command to launch an ec2 instance by providing different options like image id, key-name, security-group-id, etc. So the above command will launch one ec2 instance with Name instance.

aws ec2 create-volume

— availability-zone us-east-1a

— size 1

— volume-type gp2

— tag-specifications=ResourceType=volume,Tags=[{Key=Name,Value=WebEBS}]

Here we are providing the availability zone where this volume needs to be created and finally, it will create a volume with the tag WebEBS.

aws ec2 attach-volume

— volume-id vol-0bd8a562fef9d117c

— instance-id i-0e74a3bbbeabac766

— device /dev/sdf

This command will attach the volume with the instance. We can confirm by running “fdisk -l” from the instance.

mkfs.ext4 xvdf1

mount /dev/xvdf1 /var/www/html

aws s3api create-bucket

— bucket task-web-bucket

— region us-east-1

So an S3 bucket will be created with the name called task-web-bucket. We can verify this from the AWS management console.

aws s3 cp aws_img.jpg s3://task-web-bucket

— acl public-read

I am uploading one image called batman.jpg into the S3 bucket with permission called public-read so that anyone from the internet can read it.

aws cloudfront create-distribution

— origin-domain-name https://task-web-bucket.s3.amazonaws.com

Thank You for reading !! 🤗 🤗



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store