Chapter 6 of 12
Course Progress0 of 12 completed (0%)

AWS & Modern Cloud Architecture · Chapter 6 · ~20 min · Intermediate

Object Storage with S3 & CloudFront CDN

Master infinite, 11-nines durable cloud object storage with Amazon S3. Discover flat namespace key architecture, cost-optimizing lifecycle transition rules, and accelerate global media delivery with Amazon CloudFront CDN edge caching.

  • Understand flat object key architecture versus POSIX filesystems
  • Manage S3 storage tiers and lifecycle transition policies
  • Configure CloudFront edge caching, TTLs, and cache hit/miss behavior
  • Secure buckets with origin access control and public access blocks

Object Storage with S3 & CloudFront CDN: learn it visually

Architect durable cloud storage and edge caching: S3 buckets and flat keys, storage tiers (Standard, Infrequent Access, Glacier), lifecycle expiration, and CloudFront edge CDN distributions.

Object Storage with S3 & CloudFront CDNArchitect durable cloud storage and edge caching: S3 buckets and flat keys, storage tiers (Standard, Infrequent Access, Glacier), lifecycle expiration, and CloudFront edge CDN distributions.UNDERSTANDObject StorageFOLLOW THE FLOWCloudFront CDNAPPLY ITdurable cloudstorageObject Storage with S3 & CloudFront CDNArchitect durable cloud storage and edge caching: S3 buckets and flat keys, storage tiers (Standard, Infrequent Access, Glacier), lifecycle expiration, and CloudFront edge CDN distributions.UNDERSTANDObject StorageFOLLOW THE FLOWCloudFront CDNAPPLY ITdurable cloudstorage

1Object Storage: Why S3 is Not a File System

Traditional storage systems (like your local laptop SSD or an AWS Elastic Block Store volume) use block storage. The operating system formats the raw sectors with a filesystem like ext4 or NTFS, dividing disk blocks into directories and inodes.

Amazon S3 (Simple Storage Service) is fundamentally different: it is an object store. In S3, there are no disk sectors, no folders, and no inodes. Instead, an object consists of three parts:

  • Key: The unique UTF-8 string name that identifies the file (e.g. assets/images/logo.png).
  • Value: The raw binary data payload (from 0 bytes up to 5 Terabytes per single object).
  • Metadata: Key-value headers describing the object (e.g. Content-Type: image/png, Cache-Control: max-age=31536000).

Wrong idea: POSIX directory inodes on physical server disk

/var/www/uploads/avatars/user1.pngAssumes nested filesystem directories & inodes

Assuming S3 maintains nested directory inodes, path trees, and folder containers like an ext4 or NTFS filesystem.

Real system: Single flat key-value object store namespace

Key: "uploads/avatars/user1.png" → [Binary Blob]Flat key-value namespace · slashes are just characters

S3 has no folders. 'uploads/avatars/user1.png' is simply a single UTF-8 key string mapping to an object payload in a massive global distributed hash table.

Concept Check

In Amazon S3, what does the key '2026/quarter1/finance/report.pdf' physically represent?

2S3 Storage Classes & Lifecycle Policies

Not all data has the same access frequency. A marketing image on your homepage is requested millions of times per day, while quarterly regulatory audit logs might never be read again after 90 days. AWS provides tiered storage classes to optimize costs by up to 95%:

S3 Standard

$0.023 / GB / month. Millisecond access latency, designed for frequently accessed active websites and mobile apps.

S3 Standard-Infrequent Access (IA)

$0.0125 / GB / month. Millisecond access, lower storage cost but charges a per-GB retrieval fee. Ideal for older monthly statements.

S3 Glacier Flexible Retrieval

$0.0036 / GB / month. Secure long-term archive. Retrieval takes 1 to 5 minutes (expedited) or 3 to 5 hours (standard).

S3 Glacier Deep Archive

$0.00099 / GB / month (lowest cloud storage cost). Designed for 7-10 year compliance records. Retrieval takes 12 hours.

Instead of manually moving files between tiers, you write S3 Lifecycle Rules:

{
  "Rules": [
    {
      "ID": "MoveLogsToColdArchive",
      "Status": "Enabled",
      "Filter": { "Prefix": "logs/" },
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER" },
        { "Days": 365, "StorageClass": "DEEP_ARCHIVE" }
      ],
      "Expiration": { "Days": 2555 }
    }
  ]
}

3Accelerating Content with Amazon CloudFront CDN

When you serve static assets directly from an S3 bucket in us-east-1 (Virginia), an end user in Sydney, Australia must establish TCP and TLS handshakes over 10,000 miles of undersea fiber. This produces a Time To First Byte (TTFB) of 250ms+!

Amazon CloudFront is a Content Delivery Network (CDN) with over 600 Points of Presence (Edge Locations) worldwide. When a user requests https://cdn.example.com/logo.png:

  1. DNS Anycast Routing: The user's browser is routed to the nearest physical Edge PoP (e.g. Sydney).
  2. Edge Cache Inspection: If the file is in edge cache (X-Cache: Hit from cloudfront), CloudFront returns it in <15ms.
  3. Origin Fetch: If the file is missing (Cache Miss), CloudFront fetches it from the S3 origin over AWS's private backbone network, caches it locally, and serves the user.
Concept Check

What is the primary performance benefit of placing CloudFront in front of an S3 bucket for international users?

4Hands-On: S3 Storage Tiers & CloudFront Edge Simulator

Experiment with storage classes and CloudFront edge caching below. Toggle CloudFront on and off, simulate requests from Tokyo, Frankfurt, or Virginia, and inspect cache hits, misses, and response latencies:

S3 Storage Tiers & CloudFront CDN Edge Simulator

Bucket Origin: us-east-1

Distance to us-east-1: 6,700 miles

$0.0003 / month

Total Stored: 132.0 MB across 4 objects

S3 Objects & Storage Class TransitionsClick "Fetch" to simulate client download
KeySizeStorage TierEdge Cache StatusAction
images/hero-banner.webp2.4 MB
Edge Cached
js/bundle.vendor.js1.1 MB
Edge Cached
reports/q1-financials.pdf8.5 MB
Cold (Origin Only)
backups/database-2025.tar.gz120 MB
Cold (Origin Only)

5Securing S3 with CloudFront Origin Access Control (OAC)

A common security mistake is leaving the S3 bucket public so CloudFront can read it. When an S3 bucket is public, anyone can bypass CloudFront and download files directly from the S3 bucket URL, costing high S3 egress fees and bypassing web application firewall (WAF) protections!

The AWS best practice is Origin Access Control (OAC):

  • Keep S3 Block Public Access enabled on the bucket.
  • CloudFront signs its origin requests with AWS Signature Version 4 (SigV4).
  • The S3 Bucket Policy grants s3:GetObject strictly to the CloudFront distribution's service principal.

Predict first

If you enable CloudFront OAC on a private S3 bucket, what happens if an internet user opens the raw S3 bucket URL directly in their browser?

6Bug Hunt: Secure the S3 Origin Bucket Policy for CloudFront

A cloud engineer created an S3 bucket policy to allow CloudFront CDN caching, but images fail with 403 Forbidden, and security audit scanners flagged the policy. Fix the three service principal, action, and ARN errors below:

S3 Bucket Policy · CloudFront Origin Access Control
JSON

🎯 Find and fix the bugs in the code above, then press Run & verify to test your solution.

Need a hint?
  • The service principal must be "cloudfront.amazonaws.com", not EC2.
  • CDN distributions only need read access: change "s3:PutObject" to "s3:GetObject".
  • Resource ARN for bucket contents requires a trailing wildcard: arn:aws:s3:::production-cdn-assets/*.

7Chapter Knowledge Challenge

Validate your understanding of S3 object storage, storage classes, and CloudFront caching:

Concept Check

A healthcare organization must retain patient archive scans for 10 years. Scans are almost never retrieved, but retrieval within 12 hours is acceptable. Which storage class minimizes cost?

Concept Check

Why should you use CloudFront Origin Access Control (OAC) instead of making an S3 bucket publicly readable?

8Recap

  • Amazon S3 is an object store using flat key-value pairs rather than hierarchical POSIX directories.
  • 11-Nines Durability: S3 automatically replicates objects across multiple physical Availability Zones.
  • Lifecycle Policies automate transitions from Standard → Infrequent Access → Glacier Deep Archive, saving up to 95% on storage costs.
  • Amazon CloudFront caches assets at 600+ edge locations worldwide for sub-20ms latencies and origin shielding.
  • Origin Access Control (OAC) ensures S3 buckets remain completely private while allowing CloudFront edge access.

Ready for Chapter 7? Mark this chapter as complete to proceed:

Enjoying this free lesson? Your support helps us build more free animated chapters.

Support Us