Lesson 2 of 6 Data Integrity, Backup and Retention

Enforcing WORM Retention with S3 Object Lock

This lesson explains how S3 Object Lock provides write-once-read-many (WORM) storage that nobody can alter or delete early, meeting regulations such as SEC 17a-4 and protecting backups against ransomware and malicious administrators.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish governance mode, compliance mode and legal holds.
  • Configure default retention on a bucket.
  • Explain why retention settings are tested before compliance mode is applied.

Retention modes and legal holds

Object Lock requires versioning and stores object versions as write once, read many (WORM), and its protections differ in who can remove them early. Governance mode retention prevents most users from deleting a version or shortening its retention. Users with s3:BypassGovernanceRetention can still do so if they explicitly request a bypass, which makes governance mode suitable for testing retention settings. Compliance mode retention cannot be removed or shortened by anyone, including the root user, until it expires, which meets regulatory requirements for immutable records.

A legal hold has no expiry date and is independent of any retention period. It protects a version, for example during litigation, until a user with s3:PutObjectLegalHold removes it. The following table summarises the protections.

ProtectionWho can remove it
Governance mode retentionUsers with s3:BypassGovernanceRetention who explicitly request a bypass; good for testing
Compliance mode retentionNo one, not even root, can delete or shorten retention until it expires
Legal holdIndefinite, independent of retention; removed by someone with s3:PutObjectLegalHold

The following diagram shows an object version's life under the lock.

S3 Object Lock for seven-year trade records. The bucket's default retention in compliance mode locks every object version for seven years, and no one, administrators included, can delete it early; a lifecycle rule then expires versions. Compliance mode cannot be undone, so it is tested first in governance mode.
WORM stands for write once, read many.
Sort into groups

Governance, compliance or legal hold?

Exam skills 5.2.2 · 5.2.3

Choose the Object Lock protection for each requirement.

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

Configuring Object Lock

S3 Object Lock stores object versions in a write once, read many (WORM) model, so they cannot be deleted or overwritten until a retention date passes or while a legal hold is in place. In governance mode, users with the s3:BypassGovernanceRetention permission can still remove the protection; in compliance mode, nobody can, including the root user. The following list describes the main configuration points.

  • It can be enabled on new or existing buckets, and relies on versioning.
  • A default retention on the bucket applies to every new object version.
  • Replication preserves retention settings on replicas.
  • Retention protects versions, not keys: new versions can still be written over a locked object.
Spot the bug

A WORM configuration that is not WORM

Exam skills 5.2.2

Find the problems in this Object Lock configuration for seven-year immutable trade records.

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

Testing before committing

Compliance mode cannot be undone: objects stored with a long compliance retention cannot be deleted by anyone, even if they were stored by mistake, and the bucket that contains them cannot be deleted either. An incorrect default retention can therefore create years of unremovable storage costs. Configurations are tested first in a separate bucket using governance mode and short retention periods, and compliance mode is applied only once the configuration has been verified.

True or false

Why test Object Lock first

Exam skills 5.2.2

Check the consequences of a mistaken compliance-mode configuration.

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

Meeting a seven-year WORM requirement

A financial firm must keep trade records unalterable for seven years under a regulation that forbids anyone, including administrators, from deleting them early. The bucket is created with Object Lock and a default retention in compliance mode:

aws s3api create-bucket --bucket acme-trade-records --object-lock-enabled-for-bucket \
  --create-bucket-configuration LocationConstraint=eu-west-1
aws s3api put-object-lock-configuration --bucket acme-trade-records --object-lock-configuration \
  '{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"COMPLIANCE","Years":7}}}'

Every object version written to the bucket is now locked for seven years. A lifecycle rule expires versions after the retention period, so data is not kept longer than necessary. Because compliance mode cannot be undone, the configuration is tested first in a separate bucket using governance mode and short retention.

Check yourself

How is data kept indefinitely during litigation?

Show answer

With a legal hold, which has no expiry date.

Exam Tips

Remember for the exam

  • When a regulator requires WORM storage that even the root user cannot delete, use Object Lock compliance mode.
  • For protection that most users cannot bypass but administrators can for testing, use governance mode.
  • To keep data indefinitely during litigation, use a legal hold.
  • Set a default retention on the bucket.
  • Test Object Lock configurations in governance mode first.