S3 Object Lock

Also known as: Object Lock

On this page 7

S3 Object Lock is an Amazon S3 feature that enforces a write-once-read-many (WORM) model on individual object versions, so that a protected version cannot be deleted or overwritten until its retention period expires or its legal hold is removed. In Cloud storage, it is the standard mechanism for immutable backups, regulatory record retention and protection against ransomware or accidental deletion.

Object Lock builds on object versioning: it never prevents new versions from being written, but it guarantees that each locked version survives unchanged for as long as its protection lasts. The feature is configured at the bucket level and applied per object version, either explicitly or through a default retention rule.

How Object Lock protects object versions

Object Lock protects data by attaching retention metadata to a specific version ID and rejecting any request that would permanently remove that version early. A simple delete request without a version ID still succeeds, but it only adds a delete marker; the locked version remains intact and recoverable underneath.

Two independent controls exist. A retention period stores a retain-until date and expires automatically, while a legal hold has no date and stays in place until someone with the right permission removes it. A version can carry both at once, and it stays protected as long as either control is active.

The table below lists the elements that make up an Object Lock configuration.

ElementLevelPurpose
Object Lock enabled flagBucketTurns the feature on; cannot be turned off afterward
VersioningBucketRequired; cannot be suspended once Object Lock is on
Default retentionBucketApplies a mode and period to every new version
Retain-until dateObject versionEarliest moment the version may be deleted
Legal holdObject versionOpen-ended protection independent of dates
Elements of an Object Lock configuration

Once Object Lock is enabled on a bucket, it cannot be disabled, and versioning cannot be suspended. Existing buckets can now be enabled after creation, but the decision should still be treated as permanent architecture.

Governance mode and compliance mode

Every retention period uses one of two retention modes, which differ in who, if anyone, can override the lock. Governance mode protects against most users but allows specially authorized identities to bypass it, while compliance mode allows no override by anyone, including the account root user.

PropertyGovernance modeCompliance mode
Early deletionPossible with bypass permissionImpossible for any user
Shorten retentionPossible with bypass permissionNot allowed
Extend retentionAllowedAllowed
Change to other modeCan be upgraded to complianceCannot be downgraded
Typical useTesting, internal safeguardsRegulated records, immutable backups
Comparison of the retention modes

Bypassing governance mode requires the s3:BypassGovernanceRetention permission and an explicit bypass header on the request. This design makes override a deliberate, auditable act rather than an accident. In compliance mode, the only way to remove locked data before expiry is to close the entire AWS account, which is why compliance retention periods must be chosen with great care.

Regulatory and security use cases

Object Lock serves two broad purposes: meeting record-keeping rules that demand non-rewritable storage and hardening backups against attackers who gain administrative access. Compliance mode has been independently assessed for electronic records requirements such as SEC Rule 17a-4(f), FINRA Rule 4511 and CFTC Rule 1.31, although each organization remains responsible for its own regulatory interpretation.

The following decision table matches common scenarios with a suitable configuration.

ScenarioRecommended settingReason
Broker-dealer trade recordsCompliance mode, multi-year periodRegulation requires non-erasable storage
Ransomware-resistant backupsCompliance mode, 14 to 90 daysAttackers cannot purge restore points
Litigation preservationLegal holdDuration is unknown in advance
Pilot or staging workloadsGovernance mode, short periodAdministrators can still clean up
Audit log archivesDefault retention on the bucketEvery new log version is protected automatically
Choosing an Object Lock configuration

For security, Object Lock is most effective when combined with separate backup accounts, restrictive bucket policies and cross-region replication, so that a single compromised credential cannot reach every copy.

Several S3 controls reduce the risk of data loss, but only Object Lock enforces immutability at the storage layer regardless of identity permissions. Versioning alone keeps old versions, yet any user who can delete versions can still erase them.

ControlPrevents permanent deletionMain limitation
Object versioningNoVersions can be deleted by authorized users
MFA DeletePartlyRoot user with MFA device can still delete
Bucket policy deny rulesPartlyAdministrators can edit the policy
S3 Object LockYes, for the retention termLocked data cannot be removed early
Object Lock compared with other S3 safeguards

A storage lifecycle policy still works on a locked bucket, but it cannot expire a protected version before its retention ends. Lifecycle rules may transition locked versions to colder storage classes, which helps control long-term cost.

Operational pitfalls and cost implications

Most problems with Object Lock come from underestimating its permanence. Locked data continues to incur storage charges for the full retention term, and a misconfigured default rule can lock large volumes of temporary data that nobody can remove.

  • Overly long compliance periods create unavoidable storage cost; start with governance mode while testing.
  • Default retention applies only to new versions; existing objects need S3 Batch Operations to receive retention.
  • Delete markers can mislead operators into believing data was removed when it was only hidden.
  • Write requests need an integrity checksum, such as Content-MD5 or a supported checksum header, when Object Lock applies.
  • Replication must be configured deliberately, so that destination buckets also enforce Object Lock settings.

A sound practice is to document the retention schedule per data class, restrict who may place or remove legal holds, and monitor protected storage growth alongside other cost metrics.

In simple terms

S3 Object Lock turns a cloud storage folder into something like a sealed archive box with a timer. Once a file is placed inside and the lock is set, nobody can shred or replace it until the timer runs out.

In the strictest setting, even the account owner cannot break the seal. That is exactly what makes it useful: a hacker or a careless employee cannot destroy the records either, so important backups and legal documents stay safe.

A practical example

A regional hospital network backs up its patient-scheduling and billing databases to Amazon S3 every night. After a neighboring health system loses its backups in a ransomware attack, the infrastructure team redesigns its process around immutable restore points.

The team creates a backup bucket in a separate AWS account, enables Object Lock and sets a default compliance retention of 35 days. Lifecycle rules move versions older than 7 days to a cheaper storage class, and a legal hold is added to specific snapshots whenever the compliance office opens an investigation.

Months later, an attacker obtains administrator credentials in the production account and tries to delete the backup copies. The delete requests fail, the protected versions remain, and the hospital restores its systems from the last clean snapshot within a day instead of negotiating with the attackers.