We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

CDNs

A Content Delivery Network (CDN) is a (typically global) network of servers that caches and delivers content to users based on their geographic location.

When we give users a URL to an S3 object, they'll download that object from the S3 service in the region that our bucket lives in (for me, that's us-east-2, near Ohio in the USA).

If a user in Australia tries to download that object, they're going to have to wait for the data to travel from Ohio to Australia... and that's a long way! A CDN, like AWS CloudFront, can help with that. It takes a static asset like an image or video and caches it on servers all over the world. When a user requests the asset, they get it from the server closest to them, which saves a lot of time.

In the example above, the "origin" server is an S3 bucket, and the "edge" servers are CloudFront servers. The origin is in the US, and whenever it updates, the edge servers update their caches. Then, when a user connects in Australia, they get the copy of the asset from the edge server in Australia. Much faster!

Assignment

Let's stand up a CloudFront distribution in front of our S3 bucket.

If you're using a brand new AWS account, you may receive an error that you aren't authorized to create a CloudFront distribution. AWS limits this for new accounts. If this happens, you can contact AWS Support to request access, or skip the assignment for now.

    I'm not going to cover every possible configuration option here; read the AWS documentation if you're interested. My goal is to cover the important stuff from a conceptual standpoint.

    Behind the scenes, creating the distribution through the UI also updates the S3 bucket policy to allow the new distribution to access files in the bucket. If you want to check the policy, go back to your S3 bucket, click on the "Permissions" tab, and look for "Bucket Policy."

  1. It should look something like this when you're done: https://dkdi1medkine9a.cloudfront.net/landscape/5n4K7uoEJ-dffddffdfsdfsdf.mp4. You should be able to load that URL in the browser and see the object. Congrats, you're hitting an edge server now!

Run and submit the CLI tests after ensuring that the distribution is fully deployed.

You might be able to access your CloudFront URL in the browser while the distribution is still deploying. Wait until the distribution status is Deployed before running the CLI tests!