Volume 5 · Chapter 1 — Storage and Databases

S3 Object Storage

Goutham Mayaluri 9 min read AWSCloudS3StorageDatabases

1.1 Introduction

Amazon S3 (Simple Storage Service) is one of the most important services on AWS - a durable, virtually unlimited object store that underpins backups, data lakes, static content, logs, and document archives. For a bank it holds statements, records, and compliance data for years. S3 comes up constantly in interviews because it combines extreme durability, a tiered cost model, and security features that are easy to get wrong - the public-bucket data leak being the canonical cloud mistake. This chapter covers what S3 is, its storage classes, and how to keep data in it secure and cost-effective.

1.2 What S3 Is

S3 stores data as objects (files plus metadata) inside buckets (containers), addressed by a key, rather than as blocks or a filesystem. It’s designed for extremely high durability - your data is automatically replicated across multiple facilities within a Region, so the chance of losing an object is vanishingly small - and it scales without limit, so you never provision capacity. You access objects over an API (or the SDK/CLI), which makes S3 ideal for application data, static assets, backups, logs, and analytics data lakes. The key mental model is that S3 is object storage - not a disk you attach to a server and not a filesystem, but a highly durable, infinitely scalable store you read and write through an API.

1.3 Storage Classes and Lifecycle

S3 offers storage classes at different price-and-access trade-offs. Standard is for frequently-accessed data with immediate access. Infrequent-access classes cost less per gigabyte for data accessed rarely, with a retrieval cost. Archival classes (Glacier and deep archive) cost a fraction as much for long-term retention where retrieval can take longer. Because most stored data ages and cools - a bank statement is read a lot in its first weeks and rarely after - lifecycle policies automatically transition objects to cheaper classes as they age, and can expire them when no longer needed. This is a major cost lever: keeping years of compliance data affordable by moving old, rarely-read objects to archival storage automatically rather than paying Standard prices for cold data.


# Lifecycle rule: move statements to infrequent-access after 90 days, archive after a year.
aws s3api put-bucket-lifecycle-configuration --bucket bank-statements \
  --lifecycle-configuration '{"Rules":[{"ID":"cool-then-archive","Status":"Enabled",
    "Filter":{"Prefix":"statements/"},
    "Transitions":[{"Days":90,"StorageClass":"STANDARD_IA"},
                   {"Days":365,"StorageClass":"GLACIER"}]}]}'

1.4 Durability, Versioning, and Protection

Beyond raw durability, S3 offers features that protect data. Versioning keeps previous versions of objects, so an overwrite or delete can be undone - protecting against accidental loss and providing an audit history. Object lock and retention can make objects immutable for a period (write-once-read-many), which is important for compliance data that regulators require to be tamper-proof. Replication can copy objects to another Region for disaster recovery or to another bucket for isolation. Together these turn S3 from just durable storage into a platform for protected, compliant, recoverable data - which is why banks use it for records that must survive, remain unaltered, and be recoverable.

1.5 Securing S3

S3 security is the customer’s responsibility, and the infamous failure is the publicly-exposed bucket leaking sensitive data. The controls to prevent it: block public access at the account and bucket level (on by default now, and it should stay on for anything sensitive), grant access through tightly-scoped IAM and bucket policies rather than broad permissions, encrypt objects at rest with KMS (and enforce it so unencrypted uploads are rejected), and require encryption in transit. Access should follow least privilege - a role that can read the statements it needs and nothing more - and every access is logged for audit. The recurring lesson is that S3 doesn’t expose data unless you misconfigure it to, so the discipline is to keep public access blocked, scope permissions tightly, and encrypt by default.

1.6 Banking Production Scenario

A bank stores customer statements and compliance records in S3 with block-public-access enabled, so nothing is ever internet-reachable. Objects are encrypted at rest with customer-managed KMS keys and only specific application roles can read them - so even bucket access without key permission yields nothing. Versioning guards against accidental overwrite or deletion, and object lock makes regulatory records immutable for their required retention. A lifecycle policy moves statements to infrequent-access after 90 days and to archival storage after a year, keeping years of data affordable. Objects are replicated to a second Region for disaster recovery. Every access is logged. The result: durable, compliant, tamper-proof, cost-optimized, and private storage of sensitive records.

1.7 Troubleshooting: S3 Issues

S3 problems cluster around access, cost, and consistency. “Access denied” reading an object means the role lacks S3 permission or the KMS key permission to decrypt - grant both narrowly. A data-exposure finding means public access wasn’t blocked or a policy is too broad - block public access and tighten the policy immediately. Surprisingly high storage cost usually means data that should have aged into cheaper classes didn’t - add or fix lifecycle rules - or many old versions accumulating with versioning on. Accidental deletion or overwrite is recoverable if versioning is enabled (and preventable for compliance data with object lock). High request costs or throttling on very hot prefixes can need key-naming adjustments. The discipline is least-privilege access plus key permission, block-public-access on, encryption enforced, and lifecycle rules to control cost.

1.8 S3 Storage Classes at a Glance

Chapter 8 covers these in depth; this table anchors the cost/access trade-offs that recur across the exam.

Class Access / retrieval AZs Best for
S3 Standard Frequent, ms ≥3 Hot, frequently-accessed data
Intelligent-Tiering Auto-tiered ≥3 Unknown/changing access patterns
Standard-IA Infrequent, ms (retrieval fee) ≥3 Infrequent but needs fast access
One Zone-IA Infrequent, ms 1 Reproducible/secondary data (cheaper)
Glacier Instant Retrieval Archive, ms ≥3 Archive needing instant access
Glacier Flexible Retrieval Minutes–hours ≥3 Archive, occasional retrieval
Glacier Deep Archive Hours (cheapest) ≥3 Long-term compliance archive
Interview Question

What is S3, and how do storage classes and lifecycle policies control cost?

S3 - Simple Storage Service - is AWS’s object storage service: it stores data as objects (a file plus metadata) inside buckets, addressed by a key, and accessed over an API rather than as blocks or a filesystem. Its defining properties are extremely high durability - objects are automatically replicated across multiple facilities within a Region, so the chance of losing data is vanishingly small - and virtually unlimited scale, so you never provision capacity. That makes it ideal for backups, static content, logs, data lakes, and, for a bank, statements and compliance records kept for years. Storage classes and lifecycle policies are how you control the cost of all that data. S3 offers classes at different price-and-access trade-offs: Standard for frequently-accessed data with immediate access; infrequent-access classes that cost less per gigabyte for rarely-accessed data but add a retrieval cost; and archival classes like Glacier and deep archive that cost a fraction as much for long-term retention where retrieval can take longer. The insight that makes this a big cost lever is that most data cools over time - a statement is read frequently in its first weeks and rarely afterward - so paying Standard prices to keep years-old, rarely-read data is wasteful. Lifecycle policies automate the optimization: you define rules that automatically transition objects to cheaper classes as they age - for example move to infrequent-access after 90 days and to archival after a year - and optionally expire them when they’re no longer needed at all. This keeps large volumes of compliance data affordable because cold data drifts to cheap storage automatically, without anyone manually managing it, while recent data stays instantly accessible in Standard. So S3 is durable, unlimited object storage, and you control its cost by matching each object’s storage class to how often it’s actually accessed - using lifecycle policies to move aging data to progressively cheaper tiers automatically, which for a bank keeping years of records is the difference between an affordable and an enormous storage bill.

Interview Question

How do you keep data in S3 secure, and why do public-bucket leaks happen?

Public-bucket leaks happen because of a misunderstanding of the shared responsibility model: people assume AWS keeps their data private automatically, but configuring access and protecting data in S3 is the customer’s responsibility, so a misconfiguration - a bucket or object policy that allows public access - leaves sensitive data open to anyone on the internet. It’s not an AWS breach; AWS did its part, and the customer left the door open. To keep S3 data secure I apply several layers. First and most important, I block public access at both the account and bucket level - this is on by default now and should stay on for anything sensitive, and it’s the single control that prevents the classic leak regardless of what a policy might otherwise allow. Second, I grant access only through tightly-scoped IAM policies and bucket policies following least privilege - a role that can read exactly the objects it needs and nothing more - rather than broad or wildcard permissions, and I use resource policies carefully for any cross-account access. Third, I encrypt objects at rest with KMS, preferably customer-managed keys, and enforce it so that unencrypted uploads are rejected; because access to the KMS key is a separate permission, encryption doubles as an access boundary - someone who somehow reaches the bucket still can’t read objects without key permission. Fourth, I require encryption in transit (TLS) so data is protected on the wire. Fifth, I enable logging so every access is recorded for audit, and I can use tooling that continuously checks for and flags any bucket that becomes public. For compliance data I add versioning to recover from accidental overwrite or deletion and object lock to make records immutable. Organization-level guardrails (SCPs) that deny creating public buckets provide a backstop so no team can accidentally expose data even if they try. The overarching principle is that S3 does not expose data unless you misconfigure it to, so security is about keeping public access blocked, scoping permissions to least privilege, encrypting by default with controlled keys, and logging and monitoring access - which together make the public-leak failure essentially impossible while keeping legitimate access tightly controlled and auditable, exactly what a bank storing sensitive records requires.

Chapter Revision Notes

  • S3 is durable (replicated across facilities), virtually unlimited object storage accessed via API - for backups, content, logs, data lakes, records.
  • Storage classes trade price for access speed (Standard → infrequent-access → archival); lifecycle policies auto-transition aging data to cheaper tiers.
  • Versioning recovers from overwrite/delete; object lock makes records immutable; replication copies to another Region for DR.
  • Secure S3: block public access, least-privilege IAM/bucket policies, KMS encryption enforced, TLS in transit, access logging.
  • Public-bucket leaks are a customer misconfiguration - block public access and scope policies tightly to prevent them.