What we need to do?
1.We need to configure web server using apache on EC2 server with AWS cli
2.Document Root(/var/www/html) made persistent by mounting on EBS Block Device.
3.Static objects used in code such as pictures stored in S3
4.Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.
5.Finally place the Cloud Front URL on the webapp code for security and low latency.
STEP1:
Launching a new instances using AWS cli using windows cmd.
ec2 run-instances — image-id ami-052c08d70def0ac62 — instance-type t2.micro — key-name keyhadoop — security-group-ids sg-0114179bcf895ad1 — subnet-id subnet-c8c5cca0

STEP2:
Creating an HTML file to upload on webserver using cmd prompt.

STEP3:
Accessing our Web-page using public Ip of AWS instance
“52.66.17.70/myPage.html”

STEP4:
We have hosted a web-page using Apache now we need to use S3 service to upload the image as object inside Bucket.
So here are the steps to create s3 bucket.
aws s3 mb s3://pizza-task


STEP5:
Now uploading the photo to the s3 bucket Using:
aws s3 cp c:\users\shivansh\Desktop\pizza.jpeg s3://pizza-task

Here’s we have created a bucket with an object pizza.jpeg now making it public Manually.

STEP5:
Altering image source as:
“https://pizza-task.s3.ap-south-1.amazonaws.com/pizza.jpeg”

Now we will Access the Hosted Website where image is stored in S3

Now here’s the Important thing as our image source is located in Mumbai Region and if client from far away location tries to connect to our wep-page it will be slow, So we need to setup cloud Front to store our image as a cache and decrease the latency.
STEP6:
We would configure the CloudFront:
aws cloudfront help

aws cloudfront create-distribution help
STEP7:
## aws cloudfront create-distribution — -origin-domain-name pizza-task.s3.amazonaws.com

Now New Cloud-Distribution has been Created.

Now updating Image source code from S3 Bucket to Cloud-Front:
“https://d38712xxzbsftma.cloudfront.net/pizza.jpeg”

The Above code is stored in the EBS volume
The object(pizza.jpeg) is in the s3 bucket which is connected to the CloudFront distribution as it will provide us with low latency
Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment.

So what we have done above ??
Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment.
An edge location is where end users access services located at AWS, the cloud computing division of US-headquartered Amazon. They are located in most of the major cities around the world and are specifically used by CloudFront (CDN) to distribute content to end users to reduce latency.
