INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

Topic lessonTopic: S3: versions, retention, replication and cost

S3 Versioning explained: overwrites, deletes and recovery

S3 Versioning retains multiple versions of an object with the same key. Separate storing a new version, changing what an ordinary read sees, and permanently removing a particular version. Follow one internal report through an overwrite and a delete.

What you will learn

Distinguish keys, version IDs, current and noncurrent versions, and delete markers; explain overwrites and deletes in enabled, suspended and unversioned buckets.

Prerequisite

Know buckets, keys and objects. The example uses a versioning-enabled general purpose bucket with the necessary permissions and read conditions satisfied. vA, vB and M1 are teaching labels, not real version-ID formats or timestamps. No operation is executed.

One key can retain several data versions

A key names an object; a version ID identifies one version under that key. With versioning enabled, writing reports/monthly.pdf again adds a version. The previous content remains as a noncurrent version rather than being overwritten.

reports/monthly.pdf: operation order and retained versions
  1. Store the first report

    PUT

    A PUT creates version vA.

    • vACurrent
      Draft A

    Ordinary read: draft A

  2. Write the finished report

    PUT

    A PUT adds vB; vA remains.

    • vBCurrent
      Final B
    • vANoncurrent
      Draft A

    Ordinary read: final B

  3. Delete without a version ID

    DELETE

    Add marker M1 without removing data.

    • M1Current
      Delete marker: no data
    • vBNoncurrent
      Final B
    • vANoncurrent
      Draft A

    Ordinary read: appears deleted

  4. Read version vA explicitly

    GET · versionId=vA

    A GET does not change version order.

    • M1Current
      Delete marker: no data
    • vBNoncurrent
      Final B
    • vANoncurrent
      Draft A: the requested version

    Explicit version read: draft A

History under one key. Distinguish data versions from delete markers, which have no object data.

Choose an option to see the result and explanation.

With versioning enabled, vB is written after vA under the same key. Which data remains?
Read the answer and reason

Answer: Both vA and vB; an ordinary read selects vB · The PUT adds a distinct version. The key is unchanged, but vA remains noncurrent. Rewriting a key does not remove the previous data in this enabled example.

Choose between the latest version and an explicit version

A delete marker is a version without object data. When it is current, a GET without a version ID sees the object as deleted. Draft A and final B remain stored in this example and can be requested by version ID when the required conditions are met.

After operation 3: one key, different read targets
RequestTarget and result in this example
GET without versionIdCurrent M1; treated as deleted, with 404
GET with versionId=vAData version vA; reads draft A
GET with versionId=M1The marker itself has no data; 405

Check the permission distinction too: s3:GetObjectVersion for an explicit version and s3:GetObject for a current-version read without versionId. Knowing a key or reading its current version does not by itself establish access to older versions. Match the principal, target and permissions before interpreting a real 403 or 404.

Choose an option to see the result and explanation.

M1 is current. In the fixed example, the conditions for GET versionId=vA are satisfied. What is read?
Read the answer and reason

Answer: Draft A; M1 remains current · versionId=vA selects a read target. It does not create a version or remove a marker, so what an ordinary read sees does not change.

Deletion target: add a marker or remove a particular version

Read enabled-versioning deletes by their target
RequestChange in this fixed example
DELETE without versionIdAdds a new delete marker; retains data versions
DELETE with versionId=vBPermanently removes vB; adds no new marker
DELETE with versionId=M1Removes marker M1; the next newest retained version becomes current

Repeating DELETE without versionId does not remove current marker M1: it adds another marker. Even after removing a specified marker, another marker below it can keep the object hidden. Reason from the versions that actually remain.

Choose an option to see the result and explanation.

You intend to remove only M1 but repeat DELETE without versionId. What happens?
Read the answer and reason

Answer: Another delete marker is added · In this enabled example the request adds a marker. That is different from targeting a specific marker for removal. No actual deletion is performed here.

Suspending does not return the bucket to its unversioned state

Bucket state changes how the next write is handled
StateNext write to the same key
UnversionedVersion ID is null; replaces existing content
EnabledAdds a version with a new version ID
SuspendedWrites a null version; replaces any null version of that key

Objects that predate enabling versioning retain their null version IDs. An enabled bucket cannot return to the unversioned state; suspension changes later writes. Existing non-null versions are retained. If draft C and then revision D are written under the same key while suspended, D replaces the null version containing C.

While suspended, DELETE without versionId removes any null version under that key and inserts a null delete marker. If no null version exists, the non-null data versions remain and a marker is inserted. Do not assume that suspension preserves all data as an enabled bucket does.

Choose an option to see the result and explanation.

While suspended, C and then D are written to the same key. Which new null version remains?
Read the answer and reason

Answer: One null version containing D · A later suspended write replaces the existing null version. Older non-null versions can remain, but C and D do not both become new non-null versions.

Plan retention, read permissions and cost together

Each stored version contains the whole object, not just its differences. Keeping draft A and final B means accounting for both. Delete markers also incur a small storage charge. Disappearing from an ordinary listing does not establish zero stored data.

  1. Fix the key, bucket versioning state and operation time.
  2. Separate PUT/GET/DELETE and the presence of versionId; identify the current and retained data versions.
  3. Check the required older version and read permission, then review permanent deletion and Lifecycle separately.
  4. Choose retention and stored volume together with cost and deletion-protection conditions.

Check, then explain in your own words

  1. Explain keys and version IDs.
  2. Identify markers/data and current/noncurrent versions in the figure.
  3. Compare the next operation in enabled, suspended and unversioned states.
  4. Review retention, permissions, Lifecycle and cost together.
Check your understanding: If the current version is a delete marker, is all the data gone?

No. Distinguish retained data versions from permanently removed versions.

What an ordinary read sees is not the whole stored history. Match version IDs, bucket state, operations and applicable retention/deletion controls.

Sources and conditions checked

The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.