Create High Availability Architecture with AWS CLI Using Cloud-Front , S3 and EBS

Create High Availability Architecture with AWS CLI Using Cloud-Front , S3 and EBS


Step 1 : Launch an EC2 Instance from CLI

No alt text provided for this image
aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --subnet-id subnet-4d838b25 --security-group-ids sg-09bad2e22a528f1c5 --key-name keyhadoop
No alt text provided for this image
No alt text provided for this image

Step 2 : Now we have to create EBS volume

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

Step 3 : Attach EBS Volume to EC2 Instance

aws ec2 attach-volume --instance-id i-07b2dc52b69a548fb --volume-id vol-0e5a0b110fc226058 --device /dev/sdf
No alt text provided for this image
No alt text provided for this image

Step 4 : Now we have to configure webserver for this we have to install httpd

We have to configure webserver in launched instance. We can connect instance directly or by using putty program.

Installing httpd package

yum install httpd
No alt text provided for this image

Creating partition :

Now, we have to create partition to make document root/var/www/html.

fdisk /dev/sdf
No alt text provided for this image

Formatting partition :

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

Mounting :

 mount /dev/sdf1 /var/www/html/
No alt text provided for this image

Step 5 : Now we have to create S3 Bucket from CLI

aws s3api create-bucket --bucket lwarth456 --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1
No alt text provided for this image
No alt text provided for this image

As our bucket is ready to use. Now we have to upload our data inside bucket.

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

Now, using the above URL provided to the object by s3, we can now access the image.

No alt text provided for this image

Step 6 : Create Cloud-Front Distribution :

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

 Step 7 : Finally now we create file in EC2 instance and give the image url of Cloud-Front

No alt text provided for this image

Thank You:)


To view or add a comment, sign in

More articles by Kanchan Sharma

Others also viewed

Explore content categories