0Pricing
AWS for Backend Developers (EC2, S3, RDS, Lambda) · Lesson

Hosting Static Websites and CDN Delivery

Serve a static website straight from an S3 bucket and accelerate global delivery with a CloudFront CDN in front of it.

Hosting Static Websites and CDN Delivery is a free AWS for Backend Developers (EC2, S3, RDS, Lambda) lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS for Backend Developers (EC2, S3, RDS, Lambda) learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

S3 as a Web Server

Beyond storing files, S3 can host a static website, HTML, CSS, JS, and images, with no servers to manage. It is cheap, scalable, and a perfect fit for single-page apps and documentation sites.

Enabling Static Hosting

You enable the static website hosting feature on the bucket and specify an index document (the home page) and an error document.

Index and Error Documents

The index document (often index.html) is served for the root and folder URLs. The error document handles 4xx responses, useful for SPA routing where you point errors back to index.html.

Uploading Your Site

Sync your build output into the bucket. The AWS CLI sync command uploads only changed files.

aws s3 sync ./dist s3://my-site-bucket --delete

Content Types Matter

S3 serves files with the Content-Type stored as metadata. If a CSS file is served as plain text, browsers ignore it. The CLI usually infers types, but verify for unusual extensions.

The Website Endpoint

Static hosting exposes a regional website endpoint URL. It is HTTP only and not ideal for production, which is exactly why we add a CDN next.

http://my-site-bucket.s3-website-us-east-1.amazonaws.com

Introducing CloudFront

CloudFront is AWS's content delivery network. It caches your site at edge locations worldwide, so users get fast responses from a nearby server and your bucket sees less load.

Origins and Distributions

A CloudFront distribution points at an origin (your S3 bucket). CloudFront fetches from the origin on a cache miss and serves the cached copy on subsequent requests.

HTTPS and Custom Domains

CloudFront gives you free HTTPS via AWS Certificate Manager and lets you attach a custom domain like www.example.com, things the raw S3 endpoint cannot do.

Locking Down the Bucket

For security, keep the bucket private and let only CloudFront read it using an Origin Access Control (OAC). Visitors reach content through the CDN, never the bucket directly.

Cache Invalidation

CloudFront caches aggressively. After deploying new content, invalidate the cache so users get the latest version instead of a stale copy.

aws cloudfront create-invalidation \
  --distribution-id E123ABC \
  --paths "/*"

Quick Check

Test your static hosting knowledge.

Recap: Global Static Sites

You can now ship a static site on AWS:

  • Enable S3 static website hosting with index/error documents.
  • aws s3 sync deploys your build.
  • CloudFront adds edge caching, HTTPS, and custom domains.
  • Use OAC to keep the bucket private and invalidate the cache on deploy.

Frequently asked questions

Is the “Hosting Static Websites and CDN Delivery” lesson free?

Yes — the full text of “Hosting Static Websites and CDN Delivery” is free to read here on the web, and the AWS for Backend Developers (EC2, S3, RDS, Lambda) course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS for Backend Developers (EC2, S3, RDS, Lambda) course, upgrade to CoddyKit PRO.

What will I learn in “Hosting Static Websites and CDN Delivery”?

Serve a static website straight from an S3 bucket and accelerate global delivery with a CloudFront CDN in front of it. You practise AWS for Backend Developers (EC2, S3, RDS, Lambda) with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS for Backend Developers (EC2, S3, RDS, Lambda)?

No prior experience is required. AWS for Backend Developers (EC2, S3, RDS, Lambda) on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Hosting Static Websites and CDN Delivery” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS for Backend Developers (EC2, S3, RDS, Lambda) lesson?

Yes. Every AWS for Backend Developers (EC2, S3, RDS, Lambda) lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. S3 Buckets and Objects Explained
  2. S3 Versioning and Lifecycle Policies
  3. Securing S3 Data Access
  4. Hosting Static Websites and CDN Delivery
← Back to AWS for Backend Developers (EC2, S3, RDS, Lambda)