- Newest
- Most votes
- Most comments
S3 lifecycle rules cannot directly check for object retention settings when determining which objects to expire. When you apply a lifecycle rule with an expiration action, it will attempt to add delete markers to all objects that match the filter criteria, regardless of whether they have object retention enabled.
However, S3 Object Lock retention settings will override and prevent lifecycle expiration actions. If an object has Object Lock retention applied, the lifecycle rule will not be able to delete the object or add a delete marker until the retention period expires. This is a built-in protection mechanism of Object Lock.
For your use case, you don't need a special checkbox or rule modification. Simply:
- Apply Object Lock retention to the objects you want to protect
- Configure your lifecycle rules as needed for the rest of your objects
The objects with Object Lock retention will be automatically protected from lifecycle expiration actions until their retention periods expire. After the retention period expires, the lifecycle rules will then be able to expire those objects according to your configuration.
Note that for this to work, your bucket must have Object Lock enabled, which requires versioning to be enabled as well.
Sources
s3 lifecycle rule to ensure objects under a specific prefix (e.g., protected-data/) are never deleted | AWS re:Post
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 10 months ago

this is not true "If an object has Object Lock retention applied, the lifecycle rule will not be able to delete the object or add a delete marker until the retention period expires.", it does add a delete marker to protected objects