devHọc Dev

Week 1 - Day 4: Amazon S3 Fundamentals, Storage Classes, Versioning, Replication and Encryption

Week 1 – Day 4

This lesson combines 3 topics: Amazon S3 Fundamentals, S3 Storage Classes, S3 Versioning, Replication, Encryption.

Learning Objectives

  • Understand the concepts of bucket, object, key
  • Master S3 access control: bucket policy, ACL, IAM, Block Public Access
  • Understand S3 durability, availability, and Region
  • Know the basic features: hosting, presigned URL, CORS
  • Distinguish 7+ S3 storage classes
  • Understand retrieval pricing and minimum duration
  • Know when to use Intelligent-Tiering vs lifecycle rules
  • Apply the right storage class for each use case
  • Understand S3 Versioning and MFA Delete
  • Distinguish SRR vs CRR (replication)
  • Master 5 encryption mechanisms: SSE-S3, SSE-KMS, SSE-C, DSSE-KMS, client-side
  • Know Transfer Acceleration and Multi-Region Access Points

Part 1: Amazon S3 Fundamentals

1. S3 Overview

Amazon S3 (Simple Storage Service) = an object storage service with:

  • 99.999999999% (11 nines) durability
  • 99.99% availability (Standard class)
  • Unlimited storage, object size up to 50 TB (5 TB before 12/2025 — the exam may still use the old number)
  • Pay-as-you-go: $/GB-month + requests + data transfer

S3 in Solutions Architecture

Use caseService S3
Static website hostingS3 + CloudFront
Backup & archiveS3 + Glacier
Data lakeS3 + Athena/Redshift Spectrum
Big data analyticsS3 + EMR
Media storageS3 (image, video)
Software distributionS3 + presigned URL
Log storageS3 (centralized logs)

2. Bucket and Object

Bucket

  • A container holding objects
  • Bucket name is globally unique (not just within the account)
  • Name rules: 3-63 chars, lowercase, no underscores, DNS-compliant format
  • A bucket is created in 1 Region
  • Soft limit: 100 buckets/account (can be raised to 1000)

Object

  • Key = full path (e.g., folder/subfolder/file.txt)
  • Value = content (binary, text, image...)
  • Metadata: system + user-defined headers
  • Tags: key-value (up to 10 tags/object)
  • Version ID (if versioning is enabled)
  • Max object size 50 TB (old limit: 5 TB), max single PUT upload 5 GB (larger requires multipart)

URL Format

Path-style (legacy):
https://s3.us-east-1.amazonaws.com/my-bucket/path/to/file.txt

Virtual-hosted style (recommended):
https://my-bucket.s3.us-east-1.amazonaws.com/path/to/file.txt

AWS recommends virtual-hosted style; the plan to remove path-style has been postponed indefinitely — path-style still works today but will be removed in the future.

3. Durability vs Availability

Durability

  • 99.999999999% (11 nines) for every storage class
  • 1 object in 10 million may be lost every 10,000 years
  • Replicated across multiple AZs in the same Region (except One Zone classes)

Availability

  • Varies by storage class:
    • Standard: 99.99%
    • Standard-IA: 99.9%
    • One Zone-IA: 99.5%
    • Glacier Instant: 99.9%

4. S3 Region

Characteristics

  • An S3 bucket is created in 1 Region
  • Data does not leave the Region (unless you replicate it)
  • The bucket name is globally unique but data is stored regionally

Latency

  • Access from the same Region: ms
  • Access from another Region: higher, can be accelerated with:
    • Transfer Acceleration (via CloudFront edge)
    • Multi-Region Access Points

5. Access Control (4 mechanisms)

Access Control hierarchy

1. Block Public Access (account/bucket level) → overrides everything else
2. IAM Policy (identity-based)
3. Bucket Policy (resource-based)
4. ACL (legacy, not recommended)
5. Object-level Permission

5.1 Block Public Access (BPA)

  • A setting enabled by default for new buckets (since 2023)
  • 4 sub-settings:
    • Block public ACLs
    • Ignore public ACLs
    • Block public bucket policies
    • Restrict public bucket access (for cross-account)
  • Overrides every policy → the bucket is NOT public even if a policy allows it

5.2 IAM Policy

  • Attached to an IAM user/group/role
  • The familiar JSON format
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["s3:GetObject", "s3:PutObject"],
    "Resource": "arn:aws:s3:::my-bucket/*"
  }]
}

5.3 Bucket Policy (Resource-based)

  • Attached to the bucket
  • Principal is required
{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "PublicReadGetObject",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::my-public-bucket/*"
  }]
}
Bucket policy use cases
  • Cross-account access
  • Force HTTPS only ("aws:SecureTransport": "true")
  • Force encryption ("s3:x-amz-server-side-encryption": "AES256")
  • IP restriction ("aws:SourceIp")
  • VPC Endpoint restriction ("aws:SourceVpce")
Example: Force HTTPS
{
  "Sid": "DenyHTTP",
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:*",
  "Resource": [
    "arn:aws:s3:::my-bucket",
    "arn:aws:s3:::my-bucket/*"
  ],
  "Condition": {
    "Bool": { "aws:SecureTransport": "false" }
  }
}

5.4 ACL (Access Control List) — Legacy

  • Permissions for an object/bucket in XML form
  • Recommended to DISABLE ACLs (the default for new buckets since 2023)
  • "Object Ownership" setting: Bucket owner enforced → ACLs disabled

6. Static Website Hosting

Setup

  1. Enable "Static website hosting" in the bucket Properties
  2. Set the index document: index.html
  3. Set the error document: error.html
  4. Make the bucket public (disable BPA, add a bucket policy)

Endpoint

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

Note

  • HTTP only, no HTTPS (CloudFront is needed for HTTPS)
  • Need a custom domain → Route 53 alias or CNAME
  • Best practice: S3 (private) + CloudFront + OAC

7. Presigned URL

Definition

A URL with temporary credentials embedded, allowing 1 action (GET/PUT) on an S3 object for a limited time.

Use case

  • Let users download a private file (Premium content)
  • Upload files directly from the client to S3 (bypassing the backend)
  • Short-term file sharing

Create via CLI

aws s3 presign s3://my-bucket/private-file.pdf --expires-in 3600
# Output: https://my-bucket.s3.amazonaws.com/private-file.pdf?X-Amz-Algorithm=...

Expiration

  • CLI default: 3600s (1 hour)
  • Max: 7 days (SigV4, with long-term IAM user credentials)
  • With temporary credentials (IAM role): the URL only lives as long as the credentials' session duration (role session max 12 hours); created from the console, max 12 hours

8. CORS (Cross-Origin Resource Sharing)

When is it needed?

  • A browser on domain A calls S3 on domain B
  • The browser checks the CORS preflight

Configuration

In the bucket → Permissions → CORS:

[
  {
    "AllowedHeaders": ["*"],
    "AllowedMethods": ["GET", "PUT", "POST"],
    "AllowedOrigins": ["https://example.com"],
    "ExposeHeaders": ["ETag"],
    "MaxAgeSeconds": 3000
  }
]

9. Basic Object Operations

Upload

# Single file
aws s3 cp local.txt s3://my-bucket/

# Folder
aws s3 sync ./local-folder s3://my-bucket/remote-folder/

# Multipart upload (automatic for files > 8 MB via CLI)
aws s3 cp big-file.zip s3://my-bucket/

Multipart Upload

  • Automatic for files > 8 MB (via CLI/SDK)
  • Required for files > 5 GB
  • Benefits:
    • Resume on failure
    • Parallel upload is faster
    • Each part: 5 MB - 5 GB (except the last part)
  • Note: Multipart fails → incomplete parts are still charged (clean up with a Lifecycle rule)

Download

aws s3 cp s3://my-bucket/file.txt ./
aws s3 sync s3://my-bucket/folder/ ./local/

Delete

aws s3 rm s3://my-bucket/file.txt
aws s3 rm s3://my-bucket/folder/ --recursive

10. S3 Strong Consistency

Definition

Strong read-after-write consistency for ALL operations (since Dec 2020):

  • PUT new object → immediate GET = readable
  • UPDATE (PUT same key) → immediate GET = reads the new version
  • DELETE → GET = 404 immediately

Note

  • Before Dec 2020: only eventual consistency for UPDATE/DELETE
  • Now: 100% strong consistency, no extra cost, no perf impact

11. S3 Object Lock

Definition

Object Lock = WORM (Write Once Read Many): prevents deleting/overwriting an object for a period of time.

Modes

  • Governance Mode: users with s3:BypassGovernanceRetention can remove the lock
  • Compliance Mode: NOBODY can delete/modify (including root)

Retention

  • Retain until date: Set a timestamp
  • Legal Hold: Indefinite hold, no expiration (only users with permission can remove it)

Use case

  • Compliance (SEC Rule 17a-4, FINRA, HIPAA)
  • Ransomware-resistant backups
  • Audit logs that must be immutable

12. S3 Replication (Brief — details in Part 3 below)

2 types

  • Same-Region Replication (SRR): Replicate within the same Region
  • Cross-Region Replication (CRR): Replicate to another Region

Requirements

  • Versioning enabled on both source and destination buckets
  • An IAM role with replication permissions
  • The destination bucket exists (same or different account)

Part 2: S3 Storage Classes

1. Storage Classes Overview

ClassAvailabilityAZsMin durationRetrievalCost
S3 Standard99.99%≥3NoneInstant$$$$
S3 Intelligent-Tiering99.9%≥3NoneInstantAuto-tier
S3 Standard-IA99.9%≥330 daysInstant$$$
S3 One Zone-IA99.5%130 daysInstant$$
S3 Express One Zone99.95%11 hour< 10ms$$$$$
S3 Glacier Instant Retrieval99.9%≥390 daysInstant (ms)$
S3 Glacier Flexible Retrieval99.99%≥390 daysMin-hours$
S3 Glacier Deep Archive99.99%≥3180 days12-48 hours¢
Reduced Redundancy (deprecated)—————

2. S3 Standard

Characteristics

  • Default storage class
  • 99.99% availability
  • 11 nines durability (replicated across ≥3 AZs)
  • No retrieval fee
  • No minimum storage duration

Use case

  • Frequently accessed data
  • Static website assets
  • Mobile/gaming applications
  • Big data analytics input
  • Content distribution

3. S3 Intelligent-Tiering

Definition

S3 automatically moves objects between tiers based on access patterns, with no retrieval fee and no operational overhead.

5 tiers

Frequent Access            → Frequently accessed (Standard-equivalent)
Infrequent Access          → Not accessed for > 30 days
Archive Instant Access     → Not accessed for > 90 days (ms retrieval)
Archive Access (optional)  → > 90 days (minutes-hours retrieval, opt-in)
Deep Archive (optional)    → > 180 days (hours retrieval, opt-in)

Pricing

  • Storage cost per tier
  • Monitoring fee: $0.0025/1000 objects/month
  • NO retrieval fee between tiers

Use case

  • Data with unknown/changing access patterns
  • "Set and forget" — you don't want to manage lifecycle
  • Many TB of long-term data with unpredictable access

Note

  • Objects < 128 KB always stay in the Frequent tier (they don't qualify for other tiers)
  • Auto-archive is opt-in; by default only the first 2 tiers are used

4. S3 Standard-IA (Infrequent Access)

Characteristics

  • Accessed infrequently but needs fast (instant) access
  • 99.9% availability (lower than Standard)
  • Min storage duration: 30 days (deleting earlier → still charged for 30 days)
  • Retrieval fee: $/GB
  • ~40% cheaper than Standard

Use case

  • Backup
  • Disaster recovery files
  • Old log files that still need fast access

5. S3 One Zone-IA

Characteristics

  • Like Standard-IA but only 1 AZ
  • 99.5% availability
  • ~20% cheaper than Standard-IA
  • Data is lost if that AZ is destroyed

Use case

  • Reproducible data (can be regenerated)
  • Secondary backup copies
  • Cached data (can be replicated)

6. S3 Express One Zone (2023+)

Characteristics

  • Single-digit ms latency — the fastest S3
  • 1 AZ (like One Zone-IA)
  • Min storage duration: 1 hour
  • Costs more than Standard ~7-8x
  • Performance: millions of req/second/bucket

Use case

  • AI/ML training data (needs extremely fast I/O)
  • High-performance analytics
  • Real-time apps

Structure

  • Bucket name: my-bucket--use1-az5--x-s3
  • Requires a Directory Bucket (a new type, not a General Purpose Bucket)

7. S3 Glacier (3 tiers)

7.1 Glacier Instant Retrieval

  • Archive with instant ms retrieval (like Standard-IA but cheaper)
  • Min duration: 90 days
  • Use case: Quarterly reports, medical images that need fast retrieval

7.2 Glacier Flexible Retrieval (formerly "S3 Glacier")

  • Access in minutes - hours
  • Min duration: 90 days
  • 3 retrieval options:
    • Expedited: 1-5 minutes (most expensive)
    • Standard: 3-5 hours
    • Bulk: 5-12 hours (free — Bulk retrieval is FREE with Glacier Flexible Retrieval)

7.3 Glacier Deep Archive

  • Cheapest ($0.00099/GB-month)
  • Min duration: 180 days
  • Retrieval:
    • Standard: 12 hours
    • Bulk: 48 hours
  • Use case: 7-10 year compliance archive

Glacier comparison

ClassRetrievalMin storageCost
Glacier Instantms (instant)90 days$$
Glacier FlexibleMin-hours90 days$
Glacier Deep Archive12-48 hours180 days¢ (cheapest)

8. Lifecycle Rules

Definition

Automatically transition objects between storage classes or expire (delete) them after a period of time.

2 types of action

Transition Action
Object created → 30 days → Move to Standard-IA → 90 days → Glacier Flexible → 365 days → Glacier Deep Archive
Expiration Action
Object created → 7 days → Delete
Incomplete multipart uploads → 7 days → Delete (cleanup)

Valid transitions

Standard──►Standard-IA──►GlacierInstant──►GlacierFlexible──►GlacierDeepArchive│││▼│OneZone-IA│└──►GlacierInstant(skip)

Note

  • NO transition from Glacier back to Standard (requires restore + copy)
  • Objects < 128 KB are not transitioned (overhead cost > savings)
  • Lifecycle rules apply via prefix or tag filters

Example YAML rule

- Id: ArchiveOldLogs
  Status: Enabled
  Filter:
    Prefix: "logs/"
  Transitions:
    - Days: 30
      StorageClass: STANDARD_IA
    - Days: 90
      StorageClass: GLACIER
    - Days: 365
      StorageClass: DEEP_ARCHIVE
  Expiration:
    Days: 2555  # 7 years

9. Storage Class Selection Decision Tree

Accesspattern?│├──Frequentlyaccessed(daily)│└──Standard│├──Infrequentlyaccessed,butneedsmslatency│├──Critical(multi-AZ)││└──Standard-IA│├──Reproducible(singleAZOK)││└──OneZone-IA│└──Veryfast(<10ms,1AZ)│└──ExpressOneZone│├──Archive—needsfastretrievalwhenrequired(ms)│└──GlacierInstantRetrieval│├──Archive—minutes-hoursretrievalOK│└──GlacierFlexibleRetrieval│├──Archive—hours-dayretrievalOK│└──GlacierDeepArchive│└──Unknown/changingpattern└──Intelligent-Tiering

10. Use Case Examples

Example 1: Web application static assets

  • Hot data (CSS, JS, images frequently accessed)
  • Class: S3 Standard
  • Add: CloudFront for extra caching

Example 2: User uploads (photo sharing app)

  • Active: hot in first 30 days
  • Then: cold (rarely viewed)
  • Solution: S3 Standard → Lifecycle to Standard-IA after 30 days → Glacier Instant after 90 days

Example 3: Backup files

  • Daily backups, rarely retrieve
  • Need access within a few hours during DR
  • Solution: S3 Standard-IA (current) + Lifecycle to Glacier Flexible (90 days) + Deep Archive (1 year)

Example 4: Compliance logs (kept for 7 years)

  • Rarely accessed, waiting 12 hours for retrieval is OK
  • Solution: Direct to Glacier Deep Archive (via S3 Standard for 1 day to qualify if using lifecycle)
  • Or upload directly to Deep Archive

Example 5: ML training data

  • Read intensive during training
  • Solution: S3 Express One Zone (single-digit ms)

Example 6: Unknown access pattern, large dataset

  • A data lake whose workload changes per project
  • Solution: S3 Intelligent-Tiering

11. Pricing Breakdown (Example us-east-1)

ClassStorage $/GB-moRetrieval $/GBPUT/COPY $/1000
Standard$0.023Free$0.005
Standard-IA$0.0125$0.01$0.01
One Zone-IA$0.01$0.01$0.01
Intelligent-Tiering$0.023 (frequent) → $0.00099 (deep)Free between tiers$0.005
Glacier Instant$0.004$0.03$0.02
Glacier Flexible$0.0036$0.01 (std)$0.03
Glacier Deep Archive$0.00099$0.02 (std)$0.05

Prices may change — verify on AWS Pricing.

12. Storage Class Analysis

Definition

An S3 tool that analyzes access patterns and recommends transition to Standard-IA.

How to use

  • Enable Storage Class Analysis in the bucket's Management tab
  • After 30 days of observation, it outputs a CSV report stored in S3
  • Visualize: object age vs storage size vs access frequency
  • Integrates with Athena / QuickSight for analysis

Tip

  • Don't guess → use the tool to decide lifecycle rules

Part 3: S3 Versioning, Replication, Encryption

1. S3 Versioning

Definition

Versioning = keep multiple versions of an object instead of overwriting.

Characteristics

  • Disabled by default, enabled at the bucket level
  • When enabled:
    • Each PUT to the same key → a new version (version ID auto-generated)
    • DELETE → creates a delete marker (nothing is really deleted, old versions remain)
  • Can be disabled but cannot return to "Never enabled" (only paused → "Suspended")

Lifecycle with versioning

  • Current version policies
  • Non-current version policies (older versions): transition or expire
  • Best practice: expire non-current versions after 30-90 days to reduce cost

Restore an old version

# List versions
aws s3api list-object-versions --bucket my-bucket --prefix file.txt

# Get specific version
aws s3api get-object --bucket my-bucket --key file.txt \
  --version-id "abc123" file.txt

Use case

  • Protection against accidental delete/overwrite
  • Audit trail
  • Rollback capability

2. MFA Delete

Definition

MFA Delete = requires an MFA code to:

  • Permanently delete an object version
  • Suspend versioning on the bucket

Requirements

  • Versioning enabled
  • Only the root user can enable MFA Delete (via CLI, not the console)
  • The root user has an MFA device

Enable

aws s3api put-bucket-versioning \
  --bucket my-bucket \
  --versioning-configuration Status=Enabled,MFADelete=Enabled \
  --mfa "arn:aws:iam::111111111111:mfa/root-mfa 123456"

Use case

  • Compliance (SOX, HIPAA)
  • Protection against insider threats
  • Critical data backup

3. S3 Replication

2 types

  • SRR (Same-Region Replication): Replicate within the same Region
  • CRR (Cross-Region Replication): Replicate to another Region

Requirements for both

  • Versioning enabled on source + destination
  • An IAM role for S3 replication
  • The destination bucket can be in the same or a different account

Characteristics

  • Asynchronous replication (not real-time, usually seconds - minutes)
  • Only replicates new objects after enabling (existing objects require S3 Batch Replication)
  • Supports:
    • Replicating delete markers (optional)
    • Replicating replicas (chain replication — enabled on each bucket)
    • Replicating KMS-encrypted objects (requires granting KMS key access)

NOT replicated

  • Objects encrypted with SSE-C
  • Objects created before replication was enabled (unless using S3 Batch Replication)
  • Lifecycle actions (transitions/expirations) are not replicated

SRR use cases

  • Compliance: 2 separate copies in the same Region
  • Aggregate logs from many buckets into 1 central bucket
  • Replicate between dev and prod accounts

CRR use cases

  • Disaster recovery
  • Compliance (data residency for another region)
  • Lower latency access for global users
  • Cross-account data sharing

S3 Replication Time Control (RTC)

  • SLA: replicate 99.99% within 15 minutes
  • Costs more than standard replication
  • Use case: Critical data with a strict RPO

S3 Batch Replication

  • Replicate existing objects (already in the bucket before enabling)
  • Or replicate objects that previously failed
  • Configured via S3 Batch Operations

4. S3 Encryption (5 options)

4.1 SSE-S3 (Server-Side Encryption with S3-Managed Keys)

  • AWS fully manages the key (AES-256)
  • Header: x-amz-server-side-encryption: AES256
  • Enabled by default for every bucket (since Jan 2023)
  • Free

4.2 SSE-KMS (Server-Side with KMS Keys)

  • Key managed by AWS KMS
  • 2 key types:
    • AWS-managed CMK (alias aws/s3) — free
    • Customer-managed CMK — $1/key/month + API calls
  • Header: x-amz-server-side-encryption: aws:kms
  • Audit trail in CloudTrail (key usage)
  • Granular permissions via the KMS key policy
  • Supports bucket key to reduce KMS API call cost

4.3 DSSE-KMS (Dual-Layer SSE with KMS)

  • Encrypts twice (defense-in-depth) with different KMS keys
  • Serves regulatory requirements (DoD, government)
  • Costs double SSE-KMS
  • 2025: rarely used except for special compliance

4.4 SSE-C (Server-Side with Customer-Provided Keys)

  • The client sends the key over HTTPS with every request
  • AWS encrypts/decrypts with that key, does not store the key
  • Header: x-amz-server-side-encryption-customer-key
  • HTTPS is REQUIRED
  • Use case: Strict compliance — only the client knows the key
  • Limitation: NOT supported via the AWS Console

4.5 Client-Side Encryption

  • The client encrypts before upload and decrypts after download
  • AWS only sees ciphertext
  • SDK support: AWS Encryption SDK, S3 Encryption Client
  • Use case: End-to-end encryption, AWS never sees the plaintext

Comparison

MethodKey managed byEncryption atAudit trailUse case
SSE-S3AWS (S3)ServerNo (S3 internal only)Default, simple
SSE-KMSAWS KMS (customer-managed)ServerYes (CloudTrail)Granular control, audit
DSSE-KMSAWS KMS x2ServerYesDual-layer compliance
SSE-CCustomerServerNoCustomer holds the key
Client-SideCustomerClientN/A (AWS never sees plaintext)Zero-trust

Force encryption (bucket policy)

{
  "Sid": "DenyUnencryptedUploads",
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:PutObject",
  "Resource": "arn:aws:s3:::my-bucket/*",
  "Condition": {
    "Null": { "s3:x-amz-server-side-encryption": "true" }
  }
}

S3 Bucket Keys (reduce SSE-KMS cost)

  • By default: each object encryption → 1 KMS API call
  • Bucket Key: creates an intermediate key, reducing KMS API calls by 99%
  • Recommended when using SSE-KMS

5. S3 Transfer Acceleration

Definition

Upload/download S3 via CloudFront edge locations → faster than direct S3.

Workflow

Client(Vietnam)─►EdgeLocation(Hanoi)─►AWSbackbone─►S3(us-east-1)↑FastHTTPS

Characteristics

Use case

  • Uploads from users far from the S3 Region
  • Large file uploads (> 1 GB) cross-continent

6. S3 Multi-Region Access Points (MRAP)

Definition

A single global endpoint that routes requests to multiple S3 buckets in multiple Regions.

Workflow

Request→MRAPglobalendpoint│├──Active-activerouting│├──Bucketus-east-1│├──Bucketeu-west-1│└──Bucketap-southeast-1│└──Autofailoverifaregiongoesdown

Characteristics

  • AWS Global Accelerator routes traffic to the bucket nearest the user
  • Active-active failover: if 1 region goes down, route to another region
  • Endpoint: mfzwi23gnjvgw.mrap.accesspoint.s3-global.amazonaws.com
  • Requires enabling replication between the buckets

Use case

  • Global applications with users in many Regions
  • Active-active DR
  • Reduce latency for global reads/writes

7. S3 Access Points

Definition

Create a separate access point for each use case of a bucket, each access point with its own policy.

Characteristics

  • Each access point has:
    • A unique name (within the account)
    • Its own DNS name: <name>-<account-id>.s3-accesspoint.<region>.amazonaws.com
    • Its own policy
    • Optional VPC-only (accessible only from a VPC)
  • Simplifies access control for large buckets with 100+ applications/users

Use case

  • 1 data lake bucket used by many teams → each team gets 1 access point with its own policy
  • VPC-restricted access for internal apps

8. S3 Object Lambda

Definition

Transform data on-the-fly when GETting an object through a Lambda function, no need to duplicate the bucket.

Workflow

Client GET → Object Lambda Access Point → S3 Access Point → S3 Bucket
                  ↓
             Lambda transform data
                  ↓
             Modified data → Client

Use cases

  • Redact PII (mask SSN, credit card)
  • Resize images dynamically
  • Convert format (CSV → JSON)
  • Add a watermark
  • Different views for different users from the same object

9. S3 Storage Lens

Definition

Storage Lens = an analytics dashboard for S3 usage across the organization (all accounts, all buckets).

Characteristics

  • 30 day metrics free, 15 month historical paid
  • Default dashboard: account-wide
  • Custom dashboards: filter by Region/account/bucket/prefix
  • Recommendations: cost optimization, data protection

Metrics

  • Storage usage growth
  • Object count
  • Number of incomplete multipart uploads
  • Bucket-level encryption status
  • Top buckets by size, request count

10. S3 Inventory

Definition

Inventory = a daily/weekly CSV/Parquet report listing all objects in a bucket.

Output

  • Stored in another S3 bucket
  • Format: CSV, ORC, Parquet
  • Fields: object key, size, storage class, encryption status, replication status

Use cases

  • Bulk operations with S3 Batch
  • Audit
  • Cost analysis with Athena queries

Review Questions

  1. What is the max S3 object size? Multipart upload is required when the file is > ?

    Show answer

    The max object size is 50 TB (since 12/2025; previously 5 TB — the exam may still use the old number). A single PUT upload is max 5 GB — files > 5 GB must use Multipart Upload. AWS recommends Multipart Upload for files > 100 MB (to take advantage of parallel upload, resumability, and higher speed). Multipart Upload supports up to 10,000 parts, each 5 MB - 5 GB.

  2. Is an S3 bucket name globally unique?

    Show answer

    Yes — bucket names are unique across all of AWS (all accounts, all Regions). This is because S3 uses the bucket name in the URL: https://bucket-name.s3.amazonaws.com/. However, a bucket is created in a specific Region — the data is stored in that Region. The namespace is global but the data is regional.

  3. Does Block Public Access override a public bucket policy?

    Show answer

    Yes. Block Public Access (BPA) is the top layer — even when a bucket policy allows public access, BPA still blocks it. BPA can be set at the account level (applies to all buckets) or the bucket level. When BPA is on, any bucket policy/ACL granting public access is overridden. Best practice: enable BPA at the account level and only disable it for individual buckets that truly need to be public.

  4. Does S3 static website hosting support HTTPS?

    Show answer

    Not directly — the S3 static website endpoint only supports HTTP. For HTTPS, put CloudFront in front of the S3 bucket: CloudFront terminates TLS with an ACM certificate and serves content from S3 via HTTPS. This is the most common pattern for static websites: S3 (origin) + CloudFront (HTTPS + CDN + custom domain).

  5. Since which year has S3 had strong consistency?

    Show answer

    Since December 2020. Before that S3 had eventual consistency for overwrite PUTs and DELETEs. Since 2020, S3 provides strong read-after-write consistency for all operations (PUT, GET, DELETE, LIST) — immediately after a successful write, a read sees the latest data. No workaround is needed anymore to ensure consistency.

  6. Which storage class has a 180-day minimum duration charge?

    Show answer

    Glacier Deep Archive (180-day minimum storage duration). Deleting an object before 180 days still incurs a charge for the remainder. Other minimums: Standard-IA and One Zone-IA = 30 days, Glacier Instant Retrieval and Glacier Flexible Retrieval = 90 days, Intelligent-Tiering = 30 days. Standard and Reduced Redundancy have no minimum.

  7. When should you use S3 Intelligent-Tiering instead of a manual lifecycle?

    Show answer

    When the access pattern is unpredictable or changes over time. Intelligent-Tiering automatically monitors access frequency and moves objects between tiers (Frequent Access, Infrequent Access, Archive Instant, Archive). It suits data analytics, media assets, user-generated content — where you don't know which files will be accessed again. A manual lifecycle suits clear access patterns (e.g., logs older than 30 days are never accessed).

  8. In Intelligent-Tiering, which tier holds objects < 128 KB?

    Show answer

    The Frequent Access tier, and they are never moved to a lower tier. S3 does not monitor access or charge the monitoring fee for small objects (<128 KB) — the tiering overhead is not worth it. Small objects always stay in the Frequent Access tier. This optimization avoids monitoring cost > storage savings for small objects.

  9. How much cheaper is One Zone-IA than Standard-IA? What is the trade-off?

    Show answer

    One Zone-IA is ~20% cheaper than Standard-IA. Trade-off: data is stored in a single AZ instead of 3+ AZs — if that AZ has an incident or AWS destroys the AZ, the data is lost. Suitable for: secondary backups (a copy exists elsewhere), easily reproducible data, non-critical data. Not suitable as primary storage for data that cannot be recreated.

  10. How many retrieval options does Glacier Flexible Retrieval have?

Show answer

3 options: (1) Expedited — 1-5 minutes, most expensive (Provisioned Capacity can be used to guarantee it), (2) Standard — 3-5 hours, moderate fee, (3) Bulk — 5-12 hours, cheapest. Glacier Instant Retrieval (a different class) retrieves in milliseconds like the Standard class. Glacier Deep Archive only has Standard (12h) and Bulk (48h).

  1. Who can enable MFA Delete? What is required?
Show answer

MFA Delete can only be enabled/disabled by the bucket owner (root account) — not an IAM user even with an Admin policy. Requirements: (1) the bucket must have versioning enabled, (2) use the root account with an MFA device. Once enabled, deleting an object version or changing the versioning state requires an MFA code. It protects data against ransomware and accidental deletion.

  1. Does CRR (Cross-Region Replication) replicate objects that existed before it was enabled?
Show answer

No — CRR (and SRR) only replicates objects after replication is enabled. Objects that already existed are not replicated automatically. If you need to replicate existing objects, use S3 Batch Replication (a separate feature) or copy them manually. Versioning must also be enabled on both the source and destination buckets.

  1. Which encryption allows auditing in CloudTrail?
Show answer

SSE-KMS allows auditing key usage in CloudTrail — every object decryption creates a CloudTrail event with: who, when, which key. SSE-S3 (AWS-managed key) and SSE-C (customer-provided key) have no granular audit trail. SSE-KMS suits compliance environments that need an audit trail of every data access.

  1. What infrastructure does S3 Transfer Acceleration use?
Show answer

AWS Edge Locations (the CloudFront network). Uploads go to the nearest Edge Location, then AWS routes them optimally over the AWS backbone network to the S3 bucket. It is most effective when uploading from far away (cross-continent) because it avoids most public internet routing. You can test the speed at s3-accelerate-speedtest.s3-accelerate.amazonaws.com.

  1. What problem do Multi-Region Access Points solve?
Show answer

Multi-Region Access Points provide a single global endpoint for applications to access S3 buckets in multiple Regions. AWS automatically routes requests to the nearest bucket (lowest latency) and automatically fails over if a bucket/Region is unavailable. Combined with S3 CRR, this is an active-active multi-region storage solution for global applications.

Hands-on Exercises

Part 1: Amazon S3 Fundamentals

  • Create a private bucket, upload a few files
  • Create a public bucket with static website hosting, deploy 1 HTML page
  • Create a presigned URL for 1 object, expiring in 5 minutes
  • Apply a bucket policy forcing HTTPS, test that an HTTP request is denied
  • Enable Object Lock with Compliance mode for 7 days, try to delete
  • Set up CORS for the bucket allowing origin https://example.com

Part 2: S3 Storage Classes

  • Upload files to S3 with 3 different storage classes (Standard, Standard-IA, Glacier Instant)
  • Create a Lifecycle rule: transition prefix logs/ to Standard-IA after 30 days, Glacier after 90 days, expire after 365 days
  • Enable Storage Class Analysis for the bucket
  • Restore an object from Glacier Flexible (Expedited tier) and measure the time
  • Compare the storage price of 1 TB for each class with the Pricing Calculator

Part 3: S3 Versioning, Replication, Encryption

  • Enable versioning on a bucket, upload 3 versions of the same file, restore version 1
  • Set up CRR from a us-east-1 bucket to ap-southeast-1
  • Apply a bucket policy forcing SSE-KMS encryption with a customer-managed key
  • Enable S3 Bucket Key, monitor the KMS API call reduction
  • Set up the Storage Lens default dashboard, observe the top buckets
  • Create a daily S3 Inventory report, query it with Athena

References


Next lesson →