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.
| Element | Level | Purpose |
|---|---|---|
| Object Lock enabled flag | Bucket | Turns the feature on; cannot be turned off afterward |
| Versioning | Bucket | Required; cannot be suspended once Object Lock is on |
| Default retention | Bucket | Applies a mode and period to every new version |
| Retain-until date | Object version | Earliest moment the version may be deleted |
| Legal hold | Object version | Open-ended protection independent of dates |
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.
| Property | Governance mode | Compliance mode |
|---|---|---|
| Early deletion | Possible with bypass permission | Impossible for any user |
| Shorten retention | Possible with bypass permission | Not allowed |
| Extend retention | Allowed | Allowed |
| Change to other mode | Can be upgraded to compliance | Cannot be downgraded |
| Typical use | Testing, internal safeguards | Regulated records, immutable backups |
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.
| Scenario | Recommended setting | Reason |
|---|---|---|
| Broker-dealer trade records | Compliance mode, multi-year period | Regulation requires non-erasable storage |
| Ransomware-resistant backups | Compliance mode, 14 to 90 days | Attackers cannot purge restore points |
| Litigation preservation | Legal hold | Duration is unknown in advance |
| Pilot or staging workloads | Governance mode, short period | Administrators can still clean up |
| Audit log archives | Default retention on the bucket | Every new log version is protected automatically |
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.
How Object Lock differs from related protections
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.
| Control | Prevents permanent deletion | Main limitation |
|---|---|---|
| Object versioning | No | Versions can be deleted by authorized users |
| MFA Delete | Partly | Root user with MFA device can still delete |
| Bucket policy deny rules | Partly | Administrators can edit the policy |
| S3 Object Lock | Yes, for the retention term | Locked data cannot be removed early |
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.