Amazon S3

Object store, not a file system. Exam themes: pick the right storage class, understand replication + lifecycle, and remember the request-rate math per prefix.

Object store, không phải file system. Chủ đề exam: chọn storage class đúng, hiểu replication + lifecycle, và nhớ công thức request-rate theo prefix.

✓ Good fit✓ Hợp

  • Immutable / append-only blobs (logs, images, video)Blob immutable / append-only (log, ảnh, video)
  • Static-site hosting fronted by CloudFrontStatic site host, CloudFront ở trước
  • Data lake / analytics stagingData lake / staging cho analytics
  • Backup + tiered archiveBackup + archive tầng

✗ Anti-patterns✗ Anti-pattern

  • Millions of tiny (<10 KB) files — request cost eats youHàng triệu file bé (<10 KB) — tốn request cost
  • POSIX semantics or file locks → EFS insteadCần POSIX / file lock → EFS
  • Search / query workloads → OpenSearch or AthenaSearch / query → OpenSearch hoặc Athena
  • Rapidly-mutating rows → DynamoDB / RDSRow thay đổi liên tục → DynamoDB / RDS

Storage classes at a glanceStorage class tổng quan

All classes = 11 9s durability. What changes: availability, AZ count, min-storage-duration, min-billable-size, retrieval fee. IA + Glacier Instant bill min 128 KB per object. Mọi class đều 11 số 9 durability. Khác nhau ở availability, số AZ, min duration, min billable size, retrieval fee. IA + Glacier Instant tính tối thiểu 128 KB mỗi object.

Class AvailabilityAvailability AZsAZ Min storageMin lưu RetrievalRetrieval
Standard99.99%≥ 3——
Express One Zone99.95%1—— · single-digit ms, directory buckets— · vài ms, directory bucket
Intelligent-Tiering99.9%≥ 3—+ monitoring fee+ phí monitoring
Standard-IA99.9%≥ 330 daysngày/GB
One Zone-IA99.5%130 daysngày/GB
Glacier Instant99.9%≥ 390 daysngày/GB
Glacier Flexible99.99%≥ 390 daysngày/GB
Glacier Deep99.99%≥ 3180 daysngày/GB
ChoosingChọn Unknown access pattern → Intelligent-Tiering. Hottest data, latency-critical, compute in one AZ → Express One Zone. Known cold + still need ms latency → Glacier Instant. Cold + can wait minutes/hours → Flexible. Cold + can wait 12h → Deep. Access pattern chưa rõ → Intelligent-Tiering. Data nóng nhất, latency quan trọng, compute cùng 1 AZ → Express One Zone. Cold nhưng cần latency ms → Glacier Instant. Cold + chờ phút/giờ → Flexible. Cold + chờ 12h → Deep.

Retrieval time — how long until I can read it?Thời gian retrieval — bao lâu thì đọc được?

Only two classes make you wait: Glacier Flexible and Deep Archive are offline — you call RestoreObject, wait, and read a temporary copy. Everything else, Glacier Instant included, is a plain GET in milliseconds. Chỉ hai class bắt chờ: Glacier Flexible và Deep Archive là offline — gọi RestoreObject, chờ, rồi đọc một bản copy tạm. Mọi class còn lại, kể cả Glacier Instant, GET thẳng trong vài mili-giây.

Time until data is readable for each S3 storage class, on a logarithmic scale from one millisecond to forty-eight hours. Express One Zone answers in single-digit milliseconds. Standard, Standard-IA, One Zone-IA and Glacier Instant Retrieval answer in tens of milliseconds with a plain GET. Below a divider, the archive classes need a restore first: Glacier Flexible Retrieval takes one to five minutes with Expedited, three to five hours with Standard and five to twelve hours with free Bulk; Glacier Deep Archive takes up to twelve hours with Standard and up to forty-eight hours with Bulk. time until the first byte is readable · log scale 1 ms 1 s 1 min 1 h 12 h 48 h Express One Zone Standard · IA · One Zone-IA Glacier Instant Retrieval Glacier Flexible · Expedited Glacier Flexible · Standard Glacier Flexible · Bulk Deep Archive · Standard Deep Archive · Bulk single-digit ms tens of ms · plain GET ms · cold price, hot latency ↑ read directly ↓ RestoreObject first → temporary copy 1–5 min 3–5 h 5–12 h · free ≤ 12 h · no Expedited ≤ 48 h

The dashed line is the real divide. Above it the class only changes price; below it the class also changes how you read. Intelligent-Tiering follows the same split: its Frequent / Infrequent / Archive Instant tiers are ms, its opt-in Archive Access and Deep Archive Access tiers behave like Flexible and Deep Archive.

Đường đứt nét mới là ranh giới thật. Phía trên, class chỉ đổi giá; phía dưới, class đổi cả cách đọc. Intelligent-Tiering cũng chia y vậy: tier Frequent / Infrequent / Archive Instant là ms, còn tier opt-in Archive Access và Deep Archive Access hành xử như Flexible và Deep Archive.

Class · tier TimeThời gian Retrieval feePhí retrieval Reach for it whenChọn khi
Express One Zonesingle-digit msvài ms—latency-critical, compute in the same AZlatency là trên hết, compute cùng AZ
Standard · IA · One Zone-IAmsIA: /GBIA: /GBanything read directlymọi thứ cần đọc thẳng
Glacier Instantms/GB · highestcao nhấtread ~once a quarter, but instantlyđọc ~1 lần/quý nhưng phải có ngay
Flexible · Expedited1–5 minphúthighestcao nhấturgent restore of a few objectscần gấp vài object
Flexible · Standard3–5 hmediumvừadefault restorerestore mặc định
Flexible · Bulk5–12 hfreemiễn phílarge restores that can wait overnightrestore lớn, chờ qua đêm được
Deep Archive · Standard≤ 12 hlowthấpcompliance archive, "within 12 hours"archive compliance, "trong 12 giờ"
Deep Archive · Bulk≤ 48 hlowestthấp nhấtpetabytes, "within 2 days"hàng petabyte, "trong 2 ngày"
  • A restore is a temporary copy. You pick how many days it lives; the original stays in Flexible / Deep Archive and keeps billing there. To move it for good, restore and then copy it into another class. Restore chỉ tạo bản copy tạm. Bạn chọn số ngày nó tồn tại; bản gốc vẫn nằm ở Flexible / Deep Archive và vẫn tính tiền ở đó. Muốn chuyển hẳn thì restore rồi copy sang class khác.
  • Expedited is best-effort — under load it can be refused. Provisioned capacity units guarantee Expedited throughput; that's the answer to "guaranteed retrieval within minutes". Expedited là best-effort — lúc tải cao có thể bị từ chối. Mua Provisioned capacity mới đảm bảo throughput Expedited; đó là đáp án cho "đảm bảo lấy được trong vài phút".
  • Restoring millions of objects → S3 Batch Operations with the Standard tier; Flexible restores started this way begin returning data within minutes instead of hours. Restore hàng triệu object → S3 Batch Operations với tier Standard; restore Flexible chạy kiểu này bắt đầu trả dữ liệu sau vài phút thay vì vài giờ.
  • Know when it's done: the s3:ObjectRestore:Completed event notification fires per object — wire it to SQS / Lambda / EventBridge instead of polling. Biết khi nào xong: event s3:ObjectRestore:Completed bắn cho từng object — nối vào SQS / Lambda / EventBridge thay vì poll.
Exam reflexPhản xạ khi thi "Rarely read + must be immediate" → Glacier Instant. "Within minutes" → Flexible Expedited (+ provisioned capacity if guaranteed). "Within 12 hours, cheapest" → Deep Archive. "Within 48 hours, huge volume" → Deep Archive Bulk. "Ít đọc + phải có ngay" → Glacier Instant. "Trong vài phút" → Flexible Expedited (+ provisioned capacity nếu cần đảm bảo). "Trong 12 giờ, rẻ nhất" → Deep Archive. "Trong 48 giờ, khối lượng lớn" → Deep Archive Bulk.

Cost — where the bill actually comes fromChi phí — hoá đơn thực sự đến từ đâu

Storage per GB is the number everyone compares, and it's rarely the one that bites. Three multipliers do: minimum billable object size, minimum storage duration, and per-request costs. Together they can make a colder class cost more. Giá lưu trữ mỗi GB là con số ai cũng đem ra so, và hiếm khi là thứ gây đau. Ba hệ số nhân mới gây đau: kích thước tối thiểu tính tiền, thời gian lưu tối thiểu, và chi phí theo request. Cộng lại, một class lạnh hơn có thể tốn nhiều hơn.

The same four kilobyte object stored for ten days and read once, billed two ways. In S3 Standard it bills as four kilobytes for ten days with no retrieval fee. In S3 Standard-Infrequent Access the minimum billable object size of 128 kilobytes and the minimum storage duration of 30 days apply, plus a per-gigabyte retrieval fee — so it bills as 128 kilobytes for 30 days, thirty-two times the bytes and three times the days, despite being moved there to save money. the same 4 KB object · stored 10 days · read once S3 Standard billable size 4 KB billable days 10 retrieval fee none 4 KB × 10 days S3 Standard-IA billable size 128 KB billable days 30 retrieval fee per GB 128 KB × 30 days + retrieval 32× the bytes billed · 3× the days billed — and you moved it there to save money

The minimums are floors, not discounts. Small objects, or objects deleted early, belong in Standard — the colder classes only pay off for large objects that genuinely sit still.

Các mức tối thiểu là sàn, không phải ưu đãi. Object nhỏ, hoặc object xoá sớm, nên nằm ở Standard — các class lạnh chỉ có lãi với object lớn và thực sự nằm yên.

  • Transitions cost per request. Moving ten million tiny objects to Glacier can cost more in transition requests than the storage it saves. Lifecycle-transition the big objects; leave small ones alone, or aggregate them first. Transition tính tiền theo request. Chuyển mười triệu object nhỏ sang Glacier có thể tốn tiền request nhiều hơn phần storage tiết kiệm được. Chỉ transition object lớn; object nhỏ để yên, hoặc gộp lại trước.
  • Intelligent-Tiering doesn't auto-tier small objects. Objects under 128 KB are never moved to a colder tier and always bill at the Frequent Access rate — you pay the per-object monitoring fee for nothing. It also has no retrieval charges, which is its real selling point. Intelligent-Tiering không tự chuyển tier cho object nhỏ. Object dưới 128 KB không bao giờ được đưa xuống tier lạnh hơn và luôn tính giá Frequent Access — bạn trả phí monitoring mỗi object mà chẳng được gì. Bù lại nó không tính phí retrieval, và đó mới là điểm mạnh thật sự.
  • Incomplete multipart uploads are invisible and billed. A failed upload leaves parts that don't show in the object list but occupy storage forever. Add a lifecycle rule to abort incomplete multipart uploads after 7 days — this is the single most common silent S3 cost. Multipart upload dở dang vô hình nhưng vẫn tính tiền. Một lần upload lỗi để lại các part không hiện trong danh sách object nhưng chiếm dung lượng mãi mãi. Thêm lifecycle rule abort incomplete multipart uploads sau 7 ngày — đây là khoản chi phí S3 âm thầm phổ biến nhất.
  • On a versioned bucket, deleting an object only adds a delete marker — every old version still bills. Expire noncurrent versions and clean up expired delete markers in the same lifecycle rule. Trên bucket bật versioning, xoá object chỉ thêm một delete marker — mọi version cũ vẫn tính tiền. Hãy expire noncurrent version và dọn expired delete marker trong cùng một lifecycle rule.
Requester Pays Normally the bucket owner pays for everything. Turn on Requester Pays and the requester pays the request and data-transfer-out costs instead — the owner still always pays for storage. Requesters must be authenticated (no anonymous access), and if they call via an assumed role, the role's owner account gets the bill. This is how you publish a large dataset without funding everyone else's downloads. Bình thường chủ bucket trả tất. Bật Requester Pays thì bên gọi trả phí request và data transfer out — chủ bucket vẫn luôn trả phí storage. Bên gọi phải đã xác thực (không cho anonymous), và nếu họ gọi qua assumed role thì account sở hữu role nhận hoá đơn. Đây là cách publish một dataset lớn mà không phải è cổ trả tiền download cho thiên hạ.
Before you optimise, measureTrước khi tối ưu, hãy đo Don't guess at access patterns — Storage Class Analysis tells you which prefixes have gone cold and when, and Storage Lens shows incomplete multipart uploads and noncurrent-version bloat across every bucket. Both are covered below. Đừng đoán access pattern — Storage Class Analysis cho biết prefix nào đã nguội và nguội từ lúc nào, còn Storage Lens hiện multipart upload dở dang và lượng noncurrent version phình ra trên mọi bucket. Cả hai có ở phần dưới.

PerformancePerformance

Parallelize with multi-part upload (writes) and byte-range fetches (reads). Front global uploads with Transfer Acceleration. Song song hoá bằng multi-part upload (ghi) và byte-range fetch (đọc). Upload toàn cầu thì đặt Transfer Acceleration ở đầu.

Multi-part upload >100 MB recommended · >5 GB required>100 MB khuyến nghị · >5 GB bắt buộc
Transfer Acceleration edge → target regionedge → region đích
Byte-range fetch parallel GETs · partial file (head)GET song song · lấy 1 phần (đầu file)
Prefix sharding split hot key spacechia không gian key nóng
TrapBẫy Incomplete multi-part uploads keep costing money. Set a lifecycle rule AbortIncompleteMultipartUpload · DaysAfterInitiation: 7. Multi-part upload dở dang vẫn tính tiền. Đặt lifecycle rule AbortIncompleteMultipartUpload · DaysAfterInitiation: 7.

ReplicationReplication

A replication rule is one-way: it lives on the source and copies new objects to the destination. Two-way means two rules. A Multi-Region Access Point sits on top: one global endpoint that routes to the nearest bucket and fails over — but it moves requests, never data. Một replication rule là một chiều: nằm ở bucket nguồn và copy object mới sang đích. Hai chiều nghĩa là hai rule. Multi-Region Access Point nằm ở trên: một endpoint toàn cầu, route tới bucket gần nhất và failover — nhưng nó chuyển request, không bao giờ chuyển dữ liệu.

Three replication setups. One: a CRR or SRR rule copies new objects from bucket A to bucket B in one direction only; changes made in B never flow back. Two: two-way replication needs two rules, A to B and B to A, plus replica modification sync so metadata changes on replicas also sync. Three: a Multi-Region Access Point gives clients one global endpoint that routes each request over the AWS network to the nearest bucket, with failover to the other Region; it does not copy data itself, so the buckets underneath still need two-way replication. CRR / SRR · one-way bucket A source bucket B replica 1 rule on the source new objects only versioning on both sides writes to B never flow back two-way = 2 rules bucket A bucket B rule A→B rule B→A + replica modification sync (tag / ACL / lock edits on replicas) replicas never re-replicate → no loop Multi-Region Access Point client 1 global endpoint nearest failover bucket us-east-1 bucket eu-west-1 two-way CRR — you set it up MRAP routes, it does not copy

Read the three panels left to right as a build-up: a rule copies one way; a second rule makes it two-way; an MRAP gives clients a single name for the pair and decides which bucket answers.

Đọc ba khung từ trái qua phải như từng lớp chồng lên: một rule copy một chiều; thêm rule thứ hai thành hai chiều; MRAP cho client một cái tên duy nhất cho cặp bucket và quyết định bucket nào trả lời.

  • One-way really is one-way. Writes or deletes in the destination never reach the source. If an app writes in both Regions, a single rule silently loses half the data. Một chiều là một chiều thật. Ghi hay xoá ở bucket đích không bao giờ quay về nguồn. App ghi ở cả hai Region mà chỉ có một rule thì âm thầm mất một nửa dữ liệu.
  • Two-way = rule A→B on A + rule B→A on B, and turn on replica modification sync so tag / ACL / Object Lock changes made to a replica flow back too. No loop: a replica is never replicated again. Hai chiều = rule A→B đặt ở A + rule B→A đặt ở B, và bật replica modification sync để thay đổi tag / ACL / Object Lock trên bản replica cũng chảy ngược về. Không bị vòng lặp: replica không bao giờ được replicate tiếp.
  • Multi-Region Access Point: one global hostname; requests ride the AWS global network (Global Accelerator) to the lowest-latency bucket. Failover controls flip it active/passive in minutes. Requests must be signed with SigV4A. Multi-Region Access Point: một hostname toàn cầu; request đi trên mạng toàn cầu của AWS (Global Accelerator) tới bucket có latency thấp nhất. Failover controls chuyển sang active/passive trong vài phút. Request phải ký bằng SigV4A.
  • MRAP doesn't copy. Without replication between the buckets, a client routed to the other Region reads stale or missing objects. The standard pattern is MRAP + two-way CRR (+ RTC if the RPO needs a number). MRAP không copy dữ liệu. Không có replication giữa các bucket thì client bị route sang Region kia sẽ đọc phải object cũ hoặc thiếu. Mẫu chuẩn là MRAP + CRR hai chiều (+ RTC nếu RPO cần con số cụ thể).
  • CRR = cross-region · SRR = same-region. Both require versioning on source + destination. CRR = khác region · SRR = cùng region. Cả hai đều cần versioning ở source + đích.
  • Combine with Lifecycle Rules to tier the destination cheaper than the source. Kết hợp Lifecycle để đích tier rẻ hơn source.
  • S3 RTC — SLA-backed replication, 99.99% under 15 min. Use for compliance / cross-region DR. S3 RTC — replication có SLA, 99.99% dưới 15 phút. Dùng cho compliance / DR đa region.
  • Only new objects replicate — backfill existing ones with S3 Batch Replication. Delete markers replicate only if opted in; deletes of versions never replicate. No chaining A→B→C. Chỉ object mới được replicate — object cũ phải chạy S3 Batch Replication. Delete marker chỉ replicate nếu bật; xoá version thì không bao giờ replicate. Không chain A→B→C.
Exam reflexPhản xạ khi thi "Copy to another Region for DR / compliance" → CRR (+ RTC for a 15-minute SLA). "Apps write in both Regions" → two rules + replica modification sync. "One endpoint for a multi-Region bucket, lowest latency, automatic failover" → MRAP + two-way CRR. "Copy sang Region khác cho DR / compliance" → CRR (+ RTC nếu cần SLA 15 phút). "App ghi ở cả hai Region" → hai rule + replica modification sync. "Một endpoint cho bucket đa Region, latency thấp nhất, failover tự động" → MRAP + CRR hai chiều.

Event notificationsEvent notifications

Fire on ObjectCreated, ObjectRemoved, ObjectRestore, Replication. Filter by suffix (e.g. *.jpg). Kích hoạt trên ObjectCreated, ObjectRemoved, ObjectRestore, Replication. Filter theo suffix (vd *.jpg).

Native S3 notificationsNative S3 Via EventBridgeQua EventBridge
DestinationsĐích SQS · SNS · Lambda Step Functions · Kinesis · Firehose · many morev.v.
FilteringFilter prefix / suffixprefix / suffix JSON rules on metadata, size, nameJSON rule trên metadata, size, name
ExtrasBổ sung — Archive · replay · reliable deliveryArchive · replay · giao đúng

Logging — CloudTrail vs server access logsLogging — CloudTrail vs server access logs

CloudTrail records who called which API (an IAM identity) with guaranteed delivery — that's audit. Server access logs record every HTTP request (bytes, timing, user-agent) almost for free, but best-effort. And CloudTrail only sees object reads/writes if you turn on data events. CloudTrail ghi ai gọi API nào (danh tính IAM), có cam kết giao log — đó là audit. Server access logs ghi từng HTTP request (byte, thời gian, user-agent) gần như miễn phí, nhưng chỉ best-effort. Và CloudTrail chỉ thấy thao tác đọc/ghi object khi bạn bật data events.

Which log records which S3 activity. Bucket-level API calls such as PutBucketPolicy, DeleteBucket and PutBucketEncryption go to CloudTrail management events, which are on by default with guaranteed delivery. Object-level API calls such as GetObject, PutObject and DeleteObject go to CloudTrail data events, which must be turned on, cost per event, and also have guaranteed delivery. Every HTTP request, including anonymous requests and lifecycle actions, can go to S3 server access logs, which are nearly free but best-effort and queried with Athena. what happened on the bucket where it is recorded bucket-level API PutBucketPolicy · DeleteBucket · … CloudTrail management events on by default · guaranteed delivery object-level API GetObject · PutObject · DeleteObject CloudTrail data events opt-in · paid per event · guaranteed every HTTP request incl. anonymous · lifecycle transitions Server access logs ~free · BEST-EFFORT · query in Athena audit "who did what" → CloudTrail · traffic, bytes, hits → access logs

The trap is the middle row: CloudTrail is on by default, so it feels like everything is logged — but only bucket-level calls are. Object-level calls need data events switched on.

Bẫy nằm ở hàng giữa: CloudTrail bật sẵn nên có cảm giác mọi thứ đều được ghi — nhưng chỉ thao tác cấp bucket thôi. Thao tác cấp object phải bật data events.

CloudTrail management CloudTrail data events Server access logs
ScopePhạm vibucket-level APIAPI cấp bucketobject-level APIAPI cấp objectevery request, bucket + objectmọi request, bucket + object
Turn onBậton by default (90 d history; trail for longer)bật sẵn (giữ 90 ngày; lâu hơn cần trail)opt-in on a trail · filter by bucket / prefix / read-writetự bật trên trail · lọc theo bucket / prefix / đọc-ghiper bucket → target buckettừng bucket → bucket đích
CostChi phífirst copy freebản đầu miễn phíper event — expensive on hot bucketstheo event — đắt với bucket nóngstorage onlychỉ phí lưu
DeliveryGiao logguaranteed · log file validationđảm bảo · log file validationguaranteed · log file validationđảm bảo · log file validationbest-effort — can be late or missingbest-effort — có thể trễ hoặc thiếu
Stands outĐiểm riêngIAM ARN, source IP · CloudTrail Lake, EventBridgeIAM ARN, source IP · CloudTrail Lake, EventBridgesame, per objectnhư trên, cho từng objectHTTP status, bytes, latency, referer, anonymous hits, lifecycle actionsHTTP status, byte, latency, referer, request ẩn danh, hành động lifecycle
  • Never log a bucket into itself. Each log write is a request, which is logged, which is a write… Use a separate target bucket in the same Region. Đừng ghi access log vào chính bucket đó. Mỗi lần ghi log là một request, lại được log, lại là một lần ghi… Dùng bucket đích riêng, cùng Region.
  • Event notifications are not logs. They tell a consumer "something happened" so it can react; they aren't a complete, tamper-evident record. Event notification không phải log. Nó báo cho consumer "có chuyện xảy ra" để phản ứng; không phải bản ghi đầy đủ, chống sửa.
  • For tamper-proof audit, send the trail to a dedicated bucket with Object Lock and turn on log file validation; in an Organization, use an org trail into a log-archive account. Audit chống sửa: trail đổ vào bucket riêng có Object Lock và bật log file validation; trong Organization dùng org trail đổ về account log-archive.
Exam reflexPhản xạ khi thi "Who changed the bucket policy / deleted the bucket" → CloudTrail management events (already on). "Who read or deleted this object" / "log all activity" → CloudTrail data events. "Analyse traffic, bytes, hits — cheapest" → server access logs + Athena. "Ai sửa bucket policy / xoá bucket" → CloudTrail management events (đã bật sẵn). "Ai đọc hay xoá object này" / "log mọi hoạt động" → CloudTrail data events. "Phân tích traffic, byte, lượt truy cập — rẻ nhất" → server access logs + Athena.

Storage Lens vs Storage Class AnalysisStorage Lens vs Storage Class Analysis

  • Storage Class Analysis — decides when to move Standard → Standard-IA. Bucket-level. Daily report. Skip if you're on One Zone-IA or Glacier. Storage Class Analysis — quyết định khi nào chuyển Standard → Standard-IA. Cấp bucket. Report hằng ngày. Không dùng nếu đang One Zone-IA / Glacier.
  • Storage Lens — org-wide storage & cost insight. Free = 28 metrics for 14 days; Advanced = 15 months + prefix aggregation + CloudWatch publish. Storage Lens — nhìn tổng thể toàn org. Free = 28 metric giữ 14 ngày; Advanced = 15 tháng + gộp prefix + publish CloudWatch.

Encryption at rest — SSE-what?Mã hoá at rest — SSE-cái gì?

SSE = server-side encryption: S3 encrypts the object after it arrives and decrypts it on the way out. TLS protects data in transit; SSE protects it at rest. The suffix after the dash only ever answers one question: who manages the key. SSE = server-side encryption: S3 mã hoá object sau khi nó tới và giải mã lúc gửi ra. TLS bảo vệ dữ liệu đang truyền; SSE bảo vệ dữ liệu lúc nằm yên. Phần sau dấu gạch chỉ trả lời đúng một câu: ai quản lý key.

SSE-S3 (AES256) SSE-KMS · aws/s3 SSE-KMS · CMK SSE-C
Who manages the keyAi quản lý key S3 AWS you — policy & lifecyclebạn — policy & vòng đời you, outside AWS entirelybạn, hoàn toàn ngoài AWS
Visible in the KMS consoleThấy trong KMS console ✗ ✓ metadata only✓ chỉ metadata ✓ ✗
Edit key policy · disable · schedule deletionSửa key policy · disable · hẹn xoá ✗ ✗ ✓ —
Per-key CloudTrail audit of every useAudit CloudTrail từng lần dùng key ✗ ✓ ✓ ✗
Cross-account grants on the keyCấp quyền cross-account trên key ✗ ✗ ✓ —
Caller must send the key on every requestCaller phải gửi key trong mọi request ✗ ✗ ✗ ✓ — every PUT/GET/HEAD✓ — mọi PUT/GET/HEAD
Extra costPhí thêm nonekhông KMS requestsrequest KMS KMS key + requestskey KMS + request nonekhông
The phrase to trigger onCụm từ cần bắt "Keys managed by the company's security team" ⇒ SSE-KMS with a customer-managed key. Not SSE-S3 (S3 owns it), not aws/s3 (AWS owns it), and not SSE-C — SSE-C makes the application carry a secret in every request, which is the opposite of what a security team wants. There is also no such thing as "SSE-S3 with a customer managed key", and picking AES256 in the console is SSE-S3. "Key do security team của công ty quản lý" ⇒ SSE-KMS với customer-managed key. Không phải SSE-S3 (S3 sở hữu), không phải aws/s3 (AWS sở hữu), và không phải SSE-C — SSE-C bắt ứng dụng mang secret trong mọi request, ngược hẳn với thứ security team muốn. Cũng không có cái gọi là "SSE-S3 với customer managed key", và chọn AES256 trong console chính là SSE-S3.
Envelope encryption for SSE-KMS. When an object is uploaded, S3 asks KMS for a data key. KMS returns the same data key twice: once in plaintext and once encrypted under the KMS key. S3 uses the plaintext data key to encrypt the object, then discards the plaintext copy from memory, and stores the encrypted object alongside the encrypted data key in the object metadata. On download the process reverses: S3 sends the encrypted data key to KMS, KMS decrypts it, and S3 uses the plaintext data key to decrypt the object. A note explains that the large object is never sent to KMS, only the small data key, and that KMS request charges are therefore per object operation, not per byte. PutObject Amazon S3 asks for a data key AWS KMS GenerateDataKey returns the SAME key twice: · plaintext data key · encrypted data key encrypt the object with the plaintext key then wipe the plaintext key from memory store: ciphertext object + encrypted data key in the metadata the object itself never goes to KMS — only the small data key does, which is why KMS is billed per request, not per byte GetObject runs it backwards: encrypted data key → KMS Decrypt → plaintext key → decrypt object · S3 Bucket Keys cut these KMS calls hard

This is envelope encryption, and it's why a KMS key can protect petabytes: the KMS key never touches your data, it only wraps the per-object data key.

Đây là envelope encryption, và là lý do một KMS key bảo vệ được cả petabyte: KMS key không bao giờ chạm vào dữ liệu của bạn, nó chỉ bọc data key của từng object.

Default encryption only applies to NEW objectsDefault encryption chỉ áp cho object MỚI Changing the bucket's default encryption does nothing to objects already sitting there. To convert them you must rewrite each one — aws s3 cp --recursive in place, S3 Batch Operations copy, or CopyObject onto itself with the new encryption. Any answer that claims a bucket policy will "encrypt objects on GetObject" is inventing behaviour: reading never re-encrypts, and a bucket policy can only reject a request, never transform it. Đổi default encryption của bucket không làm gì với các object đã nằm sẵn. Muốn chuyển thì phải ghi lại từng cái — aws s3 cp --recursive tại chỗ, S3 Batch Operations copy, hoặc CopyObject lên chính nó với encryption mới. Đáp án nào nói bucket policy sẽ "mã hoá object khi GetObject" là bịa hành vi: đọc không bao giờ mã hoá lại, và bucket policy chỉ từ chối được request, không biến đổi được nó.
  • Enforce the rule with a bucket policy that denies PutObject when s3:x-amz-server-side-encryption isn't aws:kms, or when s3:x-amz-server-side-encryption-aws-kms-key-id isn't your key ARN.Ép luật bằng bucket policy deny PutObject khi s3:x-amz-server-side-encryption không phải aws:kms, hoặc khi s3:x-amz-server-side-encryption-aws-kms-key-id không phải ARN key của bạn.
  • If versioning is on, rewriting an object leaves the old, differently-encrypted version behind. You have to deal with noncurrent versions too — with versioning off, the rewrite simply overwrites.Nếu versioning đang bật, ghi lại object sẽ để lại version cũ mã hoá kiểu cũ. Phải xử lý cả noncurrent version — nếu versioning tắt, ghi lại là ghi đè luôn.
  • Reading an SSE-KMS object needs kms:Decrypt on the key as well as s3:GetObject. A cross-account reader who has the bucket policy but not the key grant gets AccessDenied — this is the most common "but I gave them access" bug.Đọc object SSE-KMS cần kms:Decrypt trên key ngoài s3:GetObject. Bên đọc cross-account có bucket policy mà không có grant trên key sẽ nhận AccessDenied — đây là lỗi "tôi đã cấp quyền rồi mà" phổ biến nhất.
  • SSE-C: S3 stores only a salted HMAC of your key to validate later requests, never the key. Lose the key, lose the data. HTTPS is mandatory.SSE-C: S3 chỉ lưu một HMAC có salt của key để kiểm tra request sau, không bao giờ lưu key. Mất key là mất dữ liệu. Bắt buộc HTTPS.
  • DSSE-KMS applies two independent layers of KMS encryption — a compliance-mandated option, not a performance one.DSSE-KMS áp hai lớp mã hoá KMS độc lập — lựa chọn do compliance bắt buộc, không phải để chạy nhanh hơn.
  • Turn on S3 Bucket Keys for KMS-encrypted buckets: S3 caches a bucket-level key and cuts KMS request charges dramatically on high-volume buckets.Bật S3 Bucket Keys cho bucket mã hoá bằng KMS: S3 cache một key ở mức bucket và giảm mạnh phí request KMS trên bucket lưu lượng cao.