Configuring web server and EC2 instance using S3 and Cloudfront on AWS CLI

Prakhar Lad
Nov 15, 2020

As you have seen in the previous blog that we have created an instance using AWS CLI. If not, then here is the link to that blog:

https://medium.com/@prakharlad22/creating-aws-ec2-instance-using-cli-e1ebded3fbb2

Web Server configured on EC2 instance

First we will install Apache Software on our created instance:

Then, creating EBS Volume and Attaching it to our instance:

Now, we have to mount Document Root i.e., (/var/www/html/) to our created EBS Volume

Creating S3 Bucket and uploading a image to the bucket

Now we will put the origin URL of the image from the bucket to check the whether the code is running or not:

AND boom, you can see the image from the above code:

Creating Cloudfront Distribution using CLI

Now, we will change the above url in the code to the domain URL we have obtained by creating the distribution over cloudfront:

Below image is the proof of above commands, that our provided Domain URL of Cloudfront Distribution:

Thank you guys for reading this blog.

Happy Learning!!!

--

--