⚡ Day 7 – Master AWS CloudFront in Minutes (Hands-on Walkthrough)

Rajesh BarikRajesh Barik
3 min read

🌍 What is Amazon CloudFront?

Imagine you run a website that has visitors from all over the world. You’ve uploaded an image or a video to your server in the US, but your users in India, Australia, or Europe find it loads slowly.
Why? Because the request has to travel thousands of miles to reach your server.

Amazon CloudFront is a Content Delivery Network (CDN) that fixes this. It stores cached versions of your content in edge locations (servers all over the world) so that users get data from the nearest location — meaning faster load times, reduced latency, and a better user experience.


💡 Why Use CloudFront?

Here’s why developers and companies love CloudFront:

  • Speed: Content is delivered from a location geographically close to the user.

  • Scalability: Handles sudden traffic spikes without breaking a sweat.

  • Security: Integrates with AWS WAF and supports HTTPS by default.

  • Cost-Efficient: Pay only for the data transfer and requests you use.

Think Netflix streaming your favorite movie without buffering — CloudFront is part of that magic.


⚙️ How CloudFront Works

  1. Origin – Your main content storage (like Amazon S3, EC2, or even a non-AWS server).

  2. Distribution – CloudFront setup that decides how content is delivered.

  3. Edge Locations – AWS’s global network of servers that cache your content.

When a user requests a file:

  • If it’s cached in a nearby edge location, CloudFront serves it instantly.

  • If not, CloudFront fetches it from the origin, caches it, and delivers it.


🛠 Hands-On: Distributing an Image Using CloudFront + S3

Let’s walk through exactly what I built today so you can try it too.


Step 1: Store an Image in Amazon S3

  1. Open the S3 console in AWS.

  2. Create a bucket – give it a unique name, enable ACLs, and set Object ownership to Object writer.

  3. Make it public – edit Block Public Access settings and deselect "Block all public access".

  4. Upload your image (e.g., myimage.jpg).

  5. Edit permissions – under Access Control List, give Everyone read access for Objects and Object ACL.

📌 Tip: In real-world apps, you rarely make your whole bucket public. For this demo, it’s okay — but in production, use signed URLs or tighter access controls.


Step 2: Create a CloudFront Distribution

  1. Go to CloudFront in AWS Console.

  2. Click Create Distribution.

  3. Origin Domain → Select your S3 bucket.

  4. Leave most defaults as they are, then click Create Distribution.

  5. Wait for status to change from Deploying to Enabled.

CloudFront will give you a domain like:

d12345abcd45xyz.cloudfront.net

You now have:

You can access your image via:

http://d12345abcd45xyz.cloudfront.net/myimage.jpg

Step 4: Cleaning Up

To avoid ongoing charges:

  • Disable & Delete your CloudFront distribution.

  • Delete the S3 object and bucket.


📦 Real-World Example

Think of CloudFront like Amazon Prime Warehouses.
Instead of shipping every product from one central warehouse (which is slow for faraway customers), Amazon stores popular items in multiple warehouses around the world.
Similarly, CloudFront keeps your content at multiple "warehouses" (edge locations) so it reaches users faster.


You’ve just built a mini CDN-powered delivery system for your image!

This is just the beginning — you can use CloudFront for:

  • Websites

  • Video streaming

  • API acceleration

  • Software downloads

And with security features like AWS WAF and SSL certificates, it’s enterprise-ready.

0
Subscribe to my newsletter

Read articles from Rajesh Barik directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rajesh Barik
Rajesh Barik