CDN with CLI : AWS CoudFront

Rahul Jain
3 min readMar 21, 2021

Task Descriptionđź“„

đź”° Create High Availability Architecture with 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

Things required for webserver configuration →→

Launching EC2 instance to configure webserver →

Creating 1GB EBS volume →

Now attaching the created EBS volume with the instance which we have created just now →

Now let see if it is connected or not by the help of putty →

- Configuring webserver on EC2 Instance by the httpd software provided by Apache →

Document Root(/var/www/html) made persistent by mounting on EBS Block Device. For this we have attached 1GB volume of EBS that will act like pen drive and we will mount /var/www/html folder with the drive to make it persistent. Now we need to do Partition of that pen drive so that we can allocate space in it. In below screenshot you can see the partition step. I forget to take screenshot of the partition of /dev/xvdf. So, I attached another volume(/dev/xvdg) and took screenshot so that you can follow same steps.

In above screenshot I format the volume and in below screenshot mount with the folder /var/www/html to make this folder persistent. And If OS got corrupt, we will not lose any data.

- Static objects used in code such as pictures stored in S3 Creating bucket in Mumbai region →

Uploading photo in the bucket →

As I put my object link in the html file and you can see that it appears in web browser.

- 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.

--

--