Skip to content

Is it possible to have an s3 rule that expires objects only when they do not have object retention ?

0

When i set object retention, im not expecting aws to add a delete market to those objects, can we get a new lifecycle rule or a checkbox to not add delete markers on those objects until the object retention expires ?

 {
     "ID": "DeleteOldChatContext",
      "Status": "Enabled",
      "Filter": {"Prefix": f"{ChatContextRepository.CHAT_CONTEXT_PATH_PREFIX}/"},
      "Expiration": {"Days": env.VOLATILE_DOCUMENTS_RETENTION_DAYS},
      "NoncurrentVersionExpiration": {"NoncurrentDays": 1},
}
asked 10 months ago200 views
1 Answer
0

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:

  1. Apply Object Lock retention to the objects you want to protect
  2. 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

answered 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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.