S3 — Object Storage

Amazon S3 in depth — buckets, keys and objects, the consistency model, durability vs availability, storage classes and lifecycle rules, versioning and Object Lock, security with Block Public Access, bucket policies and encryption, presigned URLs, multipart upload, performance and prefixes, event notifications, replication and static website hosting.

Beginner 6 min readLesson 7 of 19 Interview Q&A

Amazon S3 (Simple Storage Service) stores objects — files of any type from 0 bytes to 5 TB — in buckets, accessed over HTTPS. It's effectively unlimited, designed for 99.999999999% (11 nines) durability, and it's the backbone of data lakes, backups, media, logs, static websites and the storage under many other AWS services.

The model

s3://invoices-prod/2026/12/inv-1043.pdf
      └─ bucket ──┘ └────── key ──────┘
  • A bucket lives in one region and has a globally unique name.
  • An object = key + data + metadata (content type, custom headers, tags), with a version ID if versioning is on.
  • There are no real directories: 2026/12/ is just a key prefix; the console draws folders for convenience. Listing with Delimiter="/" simulates them.
  • Objects are immutable as a whole — you replace an object, you can't append to or edit part of it (S3 Express One Zone directory buckets are the exception, supporting appends).

Consistency

Since December 2020, S3 provides strong read-after-write consistency for all PUTs, overwrites, deletes and LIST operations, at no extra cost: once a write succeeds, every subsequent read sees it. There is no locking though — concurrent writers to one key race, and the last write wins. Use conditional writes (If-None-Match: * to create only if absent, If-Match with an ETag for compare-and-swap) to coordinate.

Durability vs availability

  • Durability (11 nines): the probability of losing data. S3 Standard stores data redundantly across at least three AZs.
  • Availability: the probability you can access it right now — 99.99% designed for Standard, lower for infrequent-access classes.

Storage classes

ClassUseRetrievalNotes
StandardFrequently accessed dataMillisecondsDefault
Intelligent-TieringUnknown or changing access patternsMilliseconds (optional archive tiers slower)Moves objects between tiers automatically for a small monitoring fee — a great default for data lakes
Standard-IAInfrequent access, needs fast retrievalMillisecondsCheaper storage, per-GB retrieval fee, 30-day minimum
One Zone-IARe-creatable infrequent dataMillisecondsSingle AZ — lost if the AZ is lost
Express One ZoneUltra-low-latency, high request ratesSingle-digit millisecondsDirectory buckets in one AZ, for ML training and analytics
Glacier Instant RetrievalArchive accessed about once a quarterMilliseconds90-day minimum
Glacier Flexible RetrievalArchivesMinutes to hoursBulk retrieval is cheapest
Glacier Deep ArchiveCompliance archives kept for yearsWithin 12–48 hoursCheapest storage of all

Lifecycle rules automate transitions and expiry:

JSON
{
  "Rules": [{
    "ID": "logs-tiering",
    "Filter": { "Prefix": "logs/" },
    "Status": "Enabled",
    "Transitions": [
      { "Days": 30,  "StorageClass": "STANDARD_IA" },
      { "Days": 90,  "StorageClass": "GLACIER" }
    ],
    "Expiration": { "Days": 365 },
    "NoncurrentVersionExpiration": { "NoncurrentDays": 30 },
    "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
  }]
}

Watch out for minimum storage durations and per-object overheads: moving millions of tiny objects to IA or Glacier can cost more than leaving them in Standard.

Versioning and protection

  • Versioning keeps every version of every object; a delete just adds a delete marker, so accidental deletes and overwrites are recoverable. Pair it with lifecycle rules that expire old versions.
  • MFA Delete requires MFA to permanently delete versions.
  • Object Lock (WORM — write once, read many): retention periods and legal holds that even the root user can't bypass in compliance mode. Used for regulatory records and ransomware-resistant backups.

Security

S3 is the most common source of cloud data leaks — almost always from misconfiguration.

  1. Block Public Access at the account and bucket level (on by default for new buckets). Leave it on unless the bucket truly is public — and even then, prefer CloudFront in front.
  2. Object Ownership = bucket owner enforced (the default): ACLs are disabled; access is controlled only by policies.
  3. Grant access with IAM policies for your own principals and bucket policies for cross-account access or conditions (IAM).
  4. Encryption at rest is automatic (SSE-S3). Use SSE-KMS when you need key-level access control and audit trails, with bucket keys to reduce KMS costs (Security on AWS).
  5. Enforce TLS with a bucket policy condition aws:SecureTransport.
  6. Restrict access to your network with VPC gateway endpoints and the aws:SourceVpce condition.
JSON
{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "DenyInsecureTransport",
    "Effect": "Deny",
    "Principal": "*",
    "Action": "s3:*",
    "Resource": ["arn:aws:s3:::invoices-prod", "arn:aws:s3:::invoices-prod/*"],
    "Condition": { "Bool": { "aws:SecureTransport": "false" } }
  }]
}

Presigned URLs

Let a browser upload or download one object directly, without making the bucket public or proxying bytes through your servers:

url = s3.generate_presigned_url(
    "put_object",
    Params={"Bucket": "uploads-prod", "Key": f"avatars/{user_id}.png", "ContentType": "image/png"},
    ExpiresIn=300,  # seconds
)
# return url to the client; it does: PUT <url> with the file body

The URL is signed with the generating principal's credentials, so it can only do what that principal can, and only until it expires.

Performance

  • Each prefix supports at least 3,500 writes and 5,500 reads per second, and S3 scales by partitioning busy prefixes automatically. Spread extreme workloads across multiple prefixes.
  • Multipart upload for anything over ~100 MB (required above 5 GB): parts upload in parallel, failed parts retry individually. Expire incomplete uploads with a lifecycle rule.
  • Byte-range GETs download large objects in parallel chunks.
  • Transfer Acceleration routes uploads through edge locations for far-away clients.
  • Put CloudFront in front for reads by end users (Route 53 and CloudFront).

Events, replication and more

  • Event notifications: object created or deleted → Lambda, SQS, SNS or EventBridge — the classic "resize image on upload" pipeline.
  • Replication: Cross-Region (CRR) for disaster recovery or latency, Same-Region (SRR) for log aggregation or account separation. Requires versioning; replicates new objects (use Batch Replication for existing ones).
  • S3 Batch Operations: run an action across billions of objects (copy, tag, restore, invoke Lambda).
  • Querying in place: Athena runs SQL over data in S3 (Parquet/ORC/JSON/CSV), the basis of data lakes; S3 Tables offer managed Apache Iceberg tables.
  • Static website hosting: possible directly, but CloudFront + a private bucket with Origin Access Control is the production pattern (HTTPS, caching, no public bucket).
Interview questions
QHow would you let users upload large files directly to S3 from the browser securely?medium

The backend authenticates the user, validates the request (size, type, destination key) and returns a presigned PUT URL, or a presigned POST policy that can enforce size limits and content type, valid for a few minutes. The browser uploads directly to S3, so the bytes never pass through the servers. For large files, use multipart upload with presigned URLs per part. The bucket stays private with Block Public Access, CORS allows only your origin, and an S3 event triggers post-processing such as virus scanning or thumbnail generation.

QWhat consistency does S3 provide?medium

Strong read-after-write consistency for PUTs of new objects, overwrites, deletes and list operations: after a successful write, any read returns the latest version. It doesn't provide locking or transactions across objects, so concurrent writers to the same key follow last-writer-wins unless you use conditional writes with If-None-Match or If-Match on the ETag.

QHow would you reduce S3 costs for a bucket of logs?easy

Apply lifecycle rules: transition to Standard-IA after 30 days, to Glacier Flexible Retrieval or Deep Archive after 90 days, and expire after the retention period; expire noncurrent versions and abort incomplete multipart uploads. Compress and batch small log files into larger objects, because per-object request and minimum-size charges make millions of tiny files expensive in IA and Glacier. Use Storage Lens or Storage Class Analysis to see actual access patterns, or Intelligent-Tiering when they're unknown.

Key takeaways
  • S3 stores immutable objects by key in regional, globally named buckets; prefixes simulate folders.
  • Strong read-after-write consistency; use conditional writes to coordinate concurrent writers.
  • 11 nines durability; pick storage classes by access pattern and automate with lifecycle rules or Intelligent-Tiering.
  • Keep Block Public Access on, use policies (not ACLs), enforce TLS and encryption, and use presigned URLs for direct client access.
  • Versioning and Object Lock protect against deletion and ransomware.
  • Use multipart upload, multiple prefixes and CloudFront for performance; S3 events drive processing pipelines.