AWS CloudFront with S3

Erwin Schleier
AWS Tip
Published in
5 min readJan 27, 2023

--

Photo by Ian Battaglia on Unsplash

CloudFront is a content delivery network, consisting of distributed servers that deliver webpages and other web content with low latency and high data transfer speed.

This gets accomplished by caching the web content at an edge location, a user will then request the content at his closest edge location. If it is already stored, he just receives it from there, otherwise, the edge location will forward the request to the actual hosting location and saves it for future requests.

AWS CloudFront Architecture

Objects are cached for a period of time which is their Time To Live. Default is 1 day but it can be changed.

CloudFront Edge Location: Location where content is cached. Separate to an AWS Region/AZ.

CloudFront Origin: Origin of all files. Can be an S3 Bucket, EC2 Instance, Elastic Load Balancer, or Route53.

CloudFront Distribution: Name given to the Origin and configuration settings for the content you wish to distribute using CloudFront (CDN).

Setup CloudFront for S3

We are going to set up the CloudFront service now. In this example, we will link CloudFront to an S3 bucket that hosts just a basic image.

Create a S3 Bucket

First, navigate to the S3 service and create a new bucket. Name it and choose an AWS region that is far away from you. As we want to be able to view the image, choose the section Object Ownership ACLs enabled.

On the section Block Public Access settings for this bucket, uncheck Block all public access and acknowledge it.

Then hit the Create bucket button! Now it’s time to upload some content in the bucket, select your previously created bucket and click on Upload. Click on Add files and choose an image that has a…

--

--