Create High Availability CloudFront Distribution with AWS CLI.

Arpit Bisane
Oct 28, 2020

> Pre-requisite:

β†’ You should know how to launch instance on AWS and attach EBS volume to the instance.

β†’ You can refer link given below for above requisite.

β†’ Firstly, we will install Apache httpd webserver on our Instance launched on AWS.

yum install httpd

β†’ Mount The Partition at Root directory of Httpd (/var/www/html)

mount /dev/xvdf1 /var/www/html

β†’ We can check mount point by following command and spot our partition.

lsblk

β†’ Now we will create S3 bucket.

aws s3 mb s3://<name of bucket> β€” region <name of region>

β†’ We can check bucket from AWS Console.

β†’After creation of bucket we will upload static data to it and set permissions to public.

aws s3 cp <location of object>/<name of object> s3://arpitbisane/helloworld.png β€” acl public-read

β†’Since our image is uploaded to bucket, now we create CloudFront Distribution for S3 bucket.

aws cloudfront create-distribution β€” origin-domain-name awsexamplebucket.s3.amazonaws.com β€” default-root-object index.html

Our Cloudfront Distribution for S3 bucket is created, We will recieve all the information about distribution.

β†’ Now configure Httpd web-server and start it.

Create a html file under /var/www/html/ folder.

β†’Now start the Httpd

β†’ Now check from the web portal.

https://<ip of your instance>/<name of file>

https://65.0.101.167/arpit.html

Our webserver is successfully launched, this static image is stored Cloudfront .

Thanks for reading this!!

for any queries regarding this article ping me on Linkedin.

--

--