-
Notifications
You must be signed in to change notification settings - Fork 5
docs: support multiple lifecycle and expiration rules per bucket #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
garrensmith
wants to merge
2
commits into
main
Choose a base branch
from
docs/multiple-lifecycle-rules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−20
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,20 @@ | ||
| # Object Expiration | ||
|
|
||
| If you use Tigris to store objects that have a limited lifetime, you can now set | ||
| up bucket lifecycle configuration rules to automatically delete them after a | ||
| If you use Tigris to store objects that have a limited lifetime, you can set up | ||
| bucket lifecycle configuration rules to automatically delete them after a | ||
| specified period. | ||
|
|
||
| ## Configuring object expiration | ||
|
|
||
| Tigris allows you to set up a expiration configuration for objects in a bucket | ||
| Tigris allows you to set up expiration configuration for objects in a bucket | ||
| through bucket lifecycle rules. The expiration is based on the last modified | ||
| time of the object. | ||
|
|
||
| A bucket can have up to **10 lifecycle rules**, which can be a mix of expiration | ||
| and transition rules scoped to different prefixes. See | ||
| [Object Lifecycle Rules](/docs/buckets/object-lifecycle-rules/) for the | ||
| transition form of these rules. | ||
|
|
||
| The expiration can be set in two ways: | ||
|
|
||
| - **Days**: The objects will be deleted after the specified number of days. | ||
|
|
@@ -29,21 +34,23 @@ bucket: | |
|
|
||
| ### Specifying expiration rules via the AWS CLI | ||
|
|
||
| You can configure expiration rules for objects in the bucket using AWS the CLI. | ||
| Below are some examples of how you can configure the expiration rules. | ||
| You can configure expiration rules for objects in the bucket using the AWS CLI. | ||
| Below are some examples. | ||
|
|
||
| #### Expire objects after 30 days | ||
|
|
||
| Here's an example of a bucket lifecycle configuration that expires objects after | ||
| 30 days. | ||
| Here's an example of a bucket lifecycle configuration that expires every object | ||
| in the bucket after 30 days. | ||
|
|
||
| Create a JSON file named `lifecycle.json` with the following content: | ||
|
|
||
| ```json | ||
| { | ||
| "Rules": [ | ||
| { | ||
| "ID": "expire-30d", | ||
| "Status": "Enabled", | ||
| "Filter": {}, | ||
| "Expiration": { | ||
| "Days": 30 | ||
| } | ||
|
|
@@ -70,7 +77,9 @@ Create a JSON file named `lifecycle.json` with the following content: | |
| { | ||
| "Rules": [ | ||
| { | ||
| "ID": "expire-eoy", | ||
| "Status": "Enabled", | ||
| "Filter": {}, | ||
| "Expiration": { | ||
| "Date": "2025-12-31T00:00:00Z" | ||
| } | ||
|
|
@@ -86,11 +95,47 @@ bucket: | |
| aws s3api put-bucket-lifecycle-configuration --bucket my-bucket --lifecycle-configuration file://lifecycle.json | ||
| ``` | ||
|
|
||
| #### Different expirations per prefix | ||
|
|
||
| Each rule can be scoped to a key prefix using `Filter.Prefix`, so different | ||
| parts of a bucket can have different expirations. The example below deletes | ||
| objects under `tmp/` after 1 day and objects under `logs/` after 30 days, while | ||
| leaving everything else untouched. | ||
|
|
||
| ```json | ||
| { | ||
| "Rules": [ | ||
| { | ||
| "ID": "expire-tmp", | ||
| "Status": "Enabled", | ||
| "Filter": { "Prefix": "tmp/" }, | ||
| "Expiration": { | ||
| "Days": 1 | ||
| } | ||
| }, | ||
| { | ||
| "ID": "expire-logs", | ||
| "Status": "Enabled", | ||
| "Filter": { "Prefix": "logs/" }, | ||
| "Expiration": { | ||
| "Days": 30 | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## Things to note | ||
|
|
||
| - A bucket can have at most 10 lifecycle rules. The 10-rule limit is shared | ||
| across expiration and transition rules. | ||
| - Each rule may include an `ID` (up to 36 characters). If you omit `ID`, Tigris | ||
| generates one. | ||
|
Comment on lines
+132
to
+133
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| - Use `Filter.Prefix` on a rule to scope it to a subset of objects. Omit | ||
| `Filter` (or pass an empty object `{}`) to apply the rule to every object in | ||
| the bucket. | ||
| - Tigris always rounds the expiration time to UTC midnight for the scheduled | ||
| date. | ||
| - The expiration time is based on the last modified time of the object. | ||
| - Only one object expiration rule can be applied to a bucket at a time. | ||
| - When using the AWS CLI to apply a bucket lifecycle configuration, the JSON can | ||
| only contain the fields shown in the examples above. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description notes that
descand*-descare reserved ID prefixes, but this constraint isn't captured anywhere in the documentation. Users who accidentally use a reserved prefix will receive an unexpected error. Consider adding a note here.