Lesson 6 of 7 Amazon S3 Data Lakes

Protecting Lake Data with Versioning, Object Lock and Replication

This lesson explains how S3 versioning, Object Lock and replication protect data in a lake against mistakes, malicious deletion and the loss of a Region, and copy it to other accounts.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how versioning, Object Lock and replication protect data.
  • Distinguish governance mode from compliance mode.
  • Manage the cost of versioning with lifecycle rules.

The features

Several S3 features protect data and copy it elsewhere. Versioning keeps every version of an object, so an overwritten or deleted object can be recovered; a delete only adds a delete marker on top. Versioning is a prerequisite for replication and Object Lock. Object Lock makes object versions write once, read many (WORM), so they cannot be changed or deleted during a retention period, which meets regulatory record-keeping requirements and protects against ransomware.

Same-Region and Cross-Region Replication copy new objects automatically to buckets in the same or another Region or account, for compliance, lower latency elsewhere or disaster recovery. Replication Time Control adds a guarantee that 99.99% of objects are copied within 15 minutes. Replication applies only to new objects, so S3 Batch Replication copies objects that existed before it was configured. The following table summarises the features.

FeatureWhat it does
VersioningKeeps every version; a delete adds a delete marker. Required for replication and Object Lock
Object LockWORM (write once, read many) storage with retention in governance or compliance mode, plus legal holds
Same-Region and Cross-Region ReplicationCopies objects to other buckets or accounts for compliance, latency or DR; Replication Time Control adds a 15-minute SLA
S3 Batch ReplicationReplicates objects that existed before replication was configured
Match the pairs

Protection and replication

Exam skills 2.3.4 · 2.3.6

Match each requirement with the S3 feature.

Log in to try this activity Interactive activities are free with an account.

Object Lock modes

Object Lock protection differs in who can remove it early. In governance mode, most users cannot delete or change a locked version, but users granted s3:BypassGovernanceRetention can. This suits internal policies and testing retention settings. In compliance mode, nobody, not even the root user, can delete the version or shorten its retention until the period ends, which is what regulations requiring immutable records need. A legal hold protects a version with no expiry date, for example during litigation, until a user with s3:PutObjectLegalHold removes it. The following table summarises the settings.

SettingWho can remove protection early
Governance modeUsers with the s3:BypassGovernanceRetention permission
Compliance modeNobody, including the root user, until the retention period ends
Legal holdUsers with s3:PutObjectLegalHold; no expiry date

The following diagram shows the protections on a bank's trade record bucket and its replica.

The bank's trade record bucket. Versioning is enabled, Object Lock in compliance mode retains each version for seven years so no user, not even root, can delete it, and Cross-Region Replication with Replication Time Control copies records to a second Region within 15 minutes. Legal holds keep records under investigation beyond retention.
CRR is Cross-Region Replication; RTC is Replication Time Control.
Scenario questions

Object Lock modes

Exam skills 2.3.6 · 2.3.5

Choose the Object Lock setting for each requirement.

Log in to try this activity Interactive activities are free with an account.

Versioning and cost

Versioning keeps every version of an object: overwriting creates a new version, and deleting adds a delete marker while the old versions remain. This protects against accidental overwrites and deletions, because any earlier version can be restored.

The cost is that storage grows silently. A data lake that rewrites files frequently, for example during compaction or Iceberg maintenance, can accumulate many times its visible size in noncurrent versions. A lifecycle rule that permanently deletes noncurrent versions after a suitable period, such as 30 days, keeps the protection against recent mistakes while controlling cost.

The following diagram shows how versions accumulate and how a lifecycle rule removes them.

How versioning grows storage. Each overwrite of part-0001.parquet adds a version, and a delete adds a delete marker while the old versions remain, so the bucket stores far more than is visible. A lifecycle rule that permanently deletes noncurrent versions after 30 days keeps recent recovery possible and controls cost.
The object name is illustrative.
Scenario questions

Versioning costs

Exam skills 2.3.4 · 2.3.2

Choose the fix for versioning costs.

Log in to try this activity Interactive activities are free with an account.
Worked example

Protecting regulated records

A bank must keep trade records unaltered for seven years, protect them from deletion by any user, and hold a copy in a second Region. The bucket is configured as described in the following table.

RequirementConfiguration
Records cannot be changed or deleted for seven yearsObject Lock in compliance mode, seven-year default retention
Prerequisite for Object Lock and replicationVersioning enabled
Copy in a second Region within 15 minutesCross-Region Replication with Replication Time Control
Records under investigation kept beyond retentionLegal holds on the affected objects

Governance mode would not meet the requirement, because users with a bypass permission could delete records. In compliance mode, not even the root user can shorten the retention.

Check yourself

What must be enabled on a bucket before Object Lock or replication can be used?

Show answer

Versioning.

Exam Tips

Remember for the exam

  • To prevent deletion during a retention period, use Object Lock.
  • Compliance mode cannot be bypassed, even by the root user.
  • Replication and Object Lock require versioning.
  • To replicate existing objects, use S3 Batch Replication.
  • Expire noncurrent versions with a lifecycle rule to control versioning cost.