Bucket lifecycle policy
A lifecycle policy lets you automatically manage the removal of objects and object versions in an evroc Object Storage Bucket. You define rules that match objects using filters and specify actions to delete current versions, remove older versions, or abort incomplete multipart uploads.
How lifecycle policies work
A lifecycle policy is a collection of rules. The system evaluates each rule against objects in the bucket. A rule identifies which objects to target using a filter and defines one or more actions to perform on matched objects.
Important: Lifecycle processing runs daily. Once you apply or update a policy, expect a delay of at least one day before the system processes your bucket.
Supported actions
A rule must specify at least one of the following actions:
- Expire current version — removes the current version of an object or adds a deletion marker in a versioned bucket
- Expire non-current versions — removes older versions of an object
- Abort incomplete multipart uploads — aborts in-progress multipart uploads that have been idle for longer than the specified number of days
Filtering objects
If you omit the filter, the rule applies to every object in the bucket. When you define a filter, you can use one or more of the following criteria, which are combined with an AND condition:
- Prefix — matches objects whose keys start with the specified string
- Tag — matches objects that have the specified key-value tags attached
- SizeGreaterThan — matches objects larger than the specified size in bytes
- SizeLessThan — matches objects smaller than the specified size in bytes
All filter properties you specify must match for the rule to apply.
Configure a lifecycle policy
You apply a lifecycle policy to a bucket using the evroc CLI. Pass the policy as a
JSON document to the --lifecycle-policy flag when creating a bucket.
Prerequisites
- An evroc Object Storage bucket in your project
Add a lifecycle rule using the evroc CLI
-
Create a JSON file that defines your lifecycle policy:
{ "rules": [ { "id": "expire-logs", "filter": { "prefix": "logs/" }, "expireCurrentVersion": { "days": 5 } } ] } -
Pass the file path to the
--lifecycle-policyflag when you create the bucket:evroc storage bucket create my-bucket \ --lifecycle-policy file://lifecycle-policy.jsonAlternatively, provide the JSON inline as a single-line string:
evroc storage bucket create my-bucket \ --lifecycle-policy '{"rules":[{"id":"expire-logs","filter":{"prefix":"logs/"},"expireCurrentVersion":{"days":5}}]}' -
The system validates the policy before applying it.
Example: expire current versions
The following rule removes the current version of objects in the archive/ prefix after 30 days:
evroc storage bucket create data-archive \
--lifecycle-policy '
{
"rules": [
{
"id": "archive-expiry",
"filter": {
"prefix": "archive/"
},
"expireCurrentVersion": {
"days": 30
}
}
]
}'
For this action, you must provide exactly one of date, days, or expireOrphanedDeletionMarkers.
If you specify a date, use an ISO 8601 format string.
Example: expire non-current versions
The following rule removes older versions of objects in the backup/ prefix that are at least 7 days old:
evroc storage bucket create data-backup \
--lifecycle-policy '
{
"rules": [
{
"id": "purge-backup-versions",
"filter": {
"prefix": "backup/"
},
"expireNonCurrentVersion": {
"days": 7
}
}
]
}'
For this action, specify exactly one of days or maxNumVersions.
Example: abort incomplete multipart uploads
The following rule aborts incomplete multipart uploads after 3 days:
evroc storage bucket create upload-bucket \
--lifecycle-policy '
{
"rules": [
{
"id": "abort-stale-uploads",
"abortIncompleteMultipart": {
"days": 3
}
}
]
}'
Reference
The following tables describe the structure of the JSON document you pass to the --lifecycle-policy flag.
lifecyclePolicy fields
| Field | Type | Description |
|---|---|---|
rules | array | The list of lifecycle rules. You must provide at least one rule. |
rules item fields
| Field | Type | Description |
|---|---|---|
id | string | A unique identifier for the rule. |
disabled | boolean | When true, the system ignores this rule. Defaults to false. |
filter | object | Optional. When present, the rule applies only to objects that match the filter criteria. |
abortIncompleteMultipart | object | Aborts incomplete multipart uploads older than the specified number of days. |
expireCurrentVersion | object | Expires the current version of an object on a specific date or after a set number of days. |
expireNonCurrentVersion | object | Expires non-current versions of an object after a set number of days or when a maximum number of versions is exceeded. |
filter fields
| Field | Type | Description |
|---|---|---|
prefix | string | Matches objects whose keys start with this prefix. |
tag | array | Matches objects that have all the specified key-value tags. Each item contains a key and a value. |
sizeGreaterThan | integer | Matches objects larger than this size in bytes. |
sizeLessThan | integer | Matches objects smaller than this size in bytes. |
abortIncompleteMultipart fields
| Field | Type | Description |
|---|---|---|
days | integer | The number of days after which the upload is aborted. Must be 1 or greater. |
expireCurrentVersion fields
| Field | Type | Description |
|---|---|---|
date | string | Expire the object on this date. Format as an ISO 8601 string. |
days | integer | Expire the object this many days after creation. Must be 1 or greater. |
expireOrphanedDeletionMarkers | boolean | Expire orphaned deletion markers. |
Important: Exactly one of
date,days, orexpireOrphanedDeletionMarkersmust be specified.
expireNonCurrentVersion fields
| Field | Type | Description |
|---|---|---|
maxNumVersions | integer | Retain at most this many versions. Must be 1 or greater. |
days | integer | Expire a non-current version after this many days. Must be 1 or greater. |
Important: Exactly one of
daysormaxNumVersionsmust be specified.