Content Delivery Networks
BACK

Content Delivery Networks

Services used: CloudFront, EC2, S3

Languages used: N/A

Objective: Decrease latency by deploying a CDN. Set up a CDN using Amazon CloudFront. Configure an EC2 instance as the origin for a CloudFront distribution. Configure an S3 hosted website as the origin for a CloudFront distribution. Reconfigure a CloudFront distribution to use an S3 website as the origin, with index.html as the main page.

First, search for and open EC2.

Select Instances then click the check box of the CDN/WebServer instance. Copy the Public IPv4 DNS.

Paste the DNS in a new page and review that the website is working and being hosted by the EC2 instance.

Next search for and open CloudFront.

Click Create a CloudFront distribution.

Paste the copied DNS and keep the other default settings.

Scroll down and select Legacy cache settings.

Scroll down and disable WAF. Scroll down and click Create distribution.

Copy the Distribution domain name then click the Distributions tab at the top.

Wait for the Status to be Enabled with a corresponding date.

Paste the copied distribution domain name and ensure that the website is being served by CloudFront.

Search for and go to S3. Select Buckets and review that there is public access. Click the bucket name.

Click the Properties tab and scroll down to the very bottom. Copy the Bucket website endpoint.

Paste in a new page to ensure the website is now hosted by the S3 bucket.

Return to CloudFront and click the Distribution ID.

Go to the Origins tab and click Edit for the EC2 origin.

Paste the S3 bucket endpoint. Scroll down and click Save changes.

Go to the General tab and under Settings click Edit.

Scroll down to Default root object. Enter index.html then click Save changes.

Copy the distribution name.

Paste in a new page and ensure the S3 bucket is being served by CloudFront. Success!