- Expiration lifecycle rules if you want to delete unnecessary objects and versions.
- Transition lifecycle rules if you want to change a storage class of objects.
Prerequisites
If you use the web console, you don’t need to complete any prerequisites.- Nebius AI Cloud CLI
- Terraform
- AWS CLI
- Go SDK
- Python SDK
- JavaScript SDK
Install and configure the Nebius AI Cloud CLI.
Install and configure the Nebius AI Cloud provider for Terraform.
How to configure expiration lifecycle rules
When you configure expiration rules, make sure that only the required objects and versions fall under these rules. Otherwise, you can unintentionally delete objects that must be preserved.
- Web console
- Nebius AI Cloud CLI
- Terraform
- AWS CLI
- Go SDK
- Python SDK
- JavaScript SDK
In the web console, you can only add lifecycle rules to existing buckets. You cannot create a bucket with a lifecycle rule.To add an expiration lifecycle rule to a bucket:
-
In the web console, go to
Storage → Object Storage.
- Open the page of the required bucket.
- Go to the Lifecycle rules tab.
-
Click
Add rule.
- (Optional) On the page that opens, specify the rule name. It helps identify the rule in a list of lifecycle rules.
-
Specify which objects the rule applies to:
-
Object key prefix: The rule applies to objects whose names begin with a specified prefix. For instance, if you set the
expiring/prefix, the rule applies to theexpiring/test.txtobject and doesn’t apply to thetest.txtobject. - Minimum size, bytes: The rule applies to objects larger than the specified size.
- Maximum size, bytes: The rule applies to objects smaller than the specified size. If you set both a minimum and maximum size, make sure that the maximum size is greater than or equal to the minimum one.
- Tags: The rule applies to objects with the specified tags. A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation.
-
Object key prefix: The rule applies to objects whose names begin with a specified prefix. For instance, if you set the
-
Set the actions that the lifecycle rule should perform:
- Expiration: Delete objects and versions several days after the object upload or on a certain date. For example, you can delete objects five days after their upload.
- Non-current version expiration: If you enabled versioning in your bucket, you can delete all versions except for the current one. To make them expire several days after the object upload, specify the required number of days.
- Abort of incomplete multipart upload: Remove multipart uploads that fail and remain stale. If they take longer than the specified number of days, Object Storage aborts multipart uploads and deletes all the data uploaded.
- Click Add rule.
When you update the settings of a bucket, make sure to list all lifecycle rules, even the ones that you do not change. If you do not include some rules, Object Storage will delete them.When you reconfigure a rule, specify only the parameters that you want to change. For example, if you earlier set a filter of objects in a rule and you want to change an expiration condition, specify only the condition, and the rule name or ID. You do not need to set the filter again as it will be preserved.To create an expiration lifecycle rule:
- Install and configure the Nebius AI Cloud CLI.
-
If you update the settings of an existing bucket, get a list of its lifecycle rules:
The rules are specified in the
nebius storage bucket get-by-name --name <bucket_name>spec.lifecycle_configuration.rulesparameter. If you want to preserve them when adding a new rule, duplicate those rules in theupdatecommand. -
To configure a new lifecycle rule, run one of the following commands:
-
Create a bucket with a lifecycle rule:
nebius storage bucket create --name <bucket_name> \ --lifecycle-configuration-rules '[ { "id": "<rule_ID>", "status": "enabled", <rule_conditions> }, { <rules_created_earlier> }, ... ]' -
Add a rule to an existing bucket:
In the
nebius storage bucket update --id <bucket_ID> \ --lifecycle-configuration-rules '[ { "id": "<rule_ID>", "status": "enabled", <rule_conditions> }, { <rules_created_earlier> }, ... ]'--idparameter, specify the bucket ID. To get it, runnebius storage bucket get-by-name --name <bucket_name>.
id: Rule ID (string). Helps identify the rule in the list of lifecycle rules.status: Whether the rule is enabled or disabled. Use thedisabledstatus to turn the rule off but preserve it in the list.
<rule_conditions>. You can combine and adapt these examples to your needs.-
To delete objects five days after their upload, specify:
"expiration": { "days": 5 } -
To delete objects whose names begin with a certain prefix, specify:
For instance, if you set the
"filter": { "prefix": "expiring/" }, "expiration": { "days": 5 }expiring/prefix, theexpiring/test.txtobject will be deleted five days after the upload, and thetest.txtobject will not. -
To delete objects that exceed 5120 bytes:
The service applies the rule five days after the object upload.
"filter": { "object_size_greater_than_bytes": 5120 }, "expiration": { "days": 5 } -
To delete objects that are less than 128 bytes:
"filter": { "object_size_less_than_bytes": 128 }, "expiration": { "days": 5 } -
To delete objects with certain tags, specify:
A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation.
"filter": { "tags": [ {"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"} ] }, "expiration": { "days": 5 } -
If you enabled versioning in your bucket, you can delete outdated versions. These are often all the versions except for the current one. To make them expire five days after they are no longer current:
"noncurrent_version_expiration": { "noncurrent_days": 5 } -
To delete all versions except for the last three:
The versions will expire five days after they are no longer current.
"noncurrent_version_expiration": { "noncurrent_days": 5, "newer_noncurrent_versions": 3 } -
If you ran multipart uploads for large objects and they failed and remained stale, abort these uploads and delete all the data uploaded. For example, to delete stale multipart uploads seven days after you initiated them (that is, after executing the
CreateMultipartUploadmethod):"abort_incomplete_multipart_upload": { "days_after_initiation": 7 }
-
Create a bucket with a lifecycle rule:
To create an expiration lifecycle rule:
- Install and configure the Nebius AI Cloud provider for Terraform.
-
Create a bucket with expiration lifecycle rules by using the following configuration file:
The file contains the following parameters:
resource "nebius_storage_v1_bucket" "<bucket_name>" { name = "<bucket_name>" parent_id = "<project_ID>" default_storage_class = "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>" versioning_policy = "ENABLED" lifecycle_configuration = { rules = [ { id = "<rule_ID>" status = "ENABLED" <rule_conditions> } ] } }-
name: Bucket name. -
parent_id: Project ID. -
default_storage_class: Default storage class. It applies to objects if a storage class isn’t set for them explicitly during the upload. -
versioning_policy: Enables versioning of objects in the bucket. For more information, see Object versioning in a bucket. -
lifecycle_configuration.rules: List of lifecycle rules. Every rule contains the following parameters:id: Rule ID (string). Helps identify the rule in the list of lifecycle rules.status: Whether the rule is enabled or disabled. Use theDISABLEDstatus to turn the rule off but preserve it in the list.
<rule_conditions>. You can combine and adapt these examples to your needs.-
To delete objects five days after their upload, specify:
expiration = { days = 5 } -
To delete objects whose names begin with a certain prefix, specify:
For instance, if you set the
expiration = { days = 5 } filter = { prefix = "expiring/" }expiring/prefix, theexpiring/test.txtobject will be deleted five days after the upload, and thetest.txtobject will not. -
To delete objects that exceed 5120 bytes:
The service applies the rule five days after the object upload.
expiration = { days = 5 } filter = { object_size_greater_than_bytes = 5120 } -
To delete objects that are less than 128 bytes:
expiration = { days = 5 } filter = { object_size_less_than_bytes = 128 } -
To delete objects with certain tags, specify:
A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation.
expiration = { days = 5 } filter = { tags = [{"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"}] } -
If you enabled versioning in your bucket, you can delete outdated versions. These are often all the versions except for the current one. To make them expire five days after they are no longer current:
noncurrent_version_expiration = { noncurrent_days = 5 } -
To delete all the versions except for the last three:
The versions will expire five days after they are no longer current.
noncurrent_version_expiration = { noncurrent_days = 5 newer_noncurrent_versions = 3 } -
If you ran multipart uploads for large objects and they failed and remained stale, abort these uploads and delete all the data uploaded. For example, to delete stale multipart uploads seven days after you initiated them (that is, after executing the
CreateMultipartUploadmethod):abort_incomplete_multipart_upload = { days_after_initiation = 7 }
-
-
Check that the configuration is correct:
terraform validate -
Apply the changes:
terraform apply
When you update the lifecycle configuration of a bucket, make sure to list all lifecycle rules and their configuration details, even the ones that you don’t change. If you don’t include some of them, the service will remove and replace them with the last lifecycle configuration.To create an expiration lifecycle rule:
- Install and configure the AWS CLI.
-
If you update the lifecycle configuration of an existing bucket, get its current lifecycle configuration:
The rules are specified in the
aws s3api get-bucket-lifecycle-configuration --bucket <bucket_name>Rulesparameter. If you want to preserve them when adding a new rule, duplicate those rules in the new JSON file that you apply to the bucket. -
To configure a new lifecycle rule, create the
lifecycle.jsonfile with lifecycle rules:{ "Rules": [ { "ID": "<rule_ID>", "Status": "Enabled", "Filter": { }, <rule_conditions> }, { <rules_created_earlier> }, ... ] } -
Apply the lifecycle configuration to the bucket:
Every rule contains the following parameters:
aws s3api put-bucket-lifecycle-configuration \ --bucket <bucket_name> \ --lifecycle-configuration file://lifecycle.jsonID: Rule ID (string). Helps identify the rule in the list of lifecycle rules.Status: Whether the rule is enabled or disabled. Use theDisabledstatus to turn the rule off but preserve it in the list.
<rule_conditions>. You can combine and adapt these examples to your needs.-
To delete objects five days after their upload, specify:
"Expiration": { "Days": 5 } -
To delete objects whose names begin with a certain prefix, specify:
For instance, if you set the
"Filter": { "Prefix": "expiring/" }, "Expiration": { "Days": 5 }expiring/prefix, theexpiring/test.txtobject will be deleted five days after the upload, and thetest.txtobject will not. -
To delete objects that exceed 5120 bytes:
The service applies the rule five days after the object upload.
"Filter": { "ObjectSizeGreaterThan": 5120 }, "Expiration": { "Days": 5 } -
To delete objects that are less than 128 bytes:
"Filter": { "ObjectSizeLessThan": 128 }, "Expiration": { "Days": 5 } -
To delete objects with a certain tag, specify:
A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation. If you want to set several tags, specify:
"Filter": { "Tag": { "Key": "key1", "Value": "value1"} }, "Expiration": { "Days": 5 }"Filter": { "And": { "Tags": [{"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"}] } }, "Expiration": { "Days": 5 } -
If you enabled versioning in your bucket, you can delete outdated versions. These are often all the versions except for the current one. To make them expire five days after they are no longer current:
"Filter": { }, "NoncurrentVersionExpiration": { "NoncurrentDays": 5 } -
To delete all versions except for the last three:
The versions will expire five days after they are no longer current.
"Filter": { }, "NoncurrentVersionExpiration": { "NoncurrentDays": 5, "NewerNoncurrentVersions": 3 } -
If you ran multipart uploads for large objects and they failed and remained stale, abort these uploads and delete all the data uploaded. For example, to delete stale multipart uploads seven days after you initiated them:
"Filter": { }, "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
To create an expiration lifecycle rule:
-
If you update an existing bucket, get its current lifecycle rules:
In the code, set
listRuleSvc := sdk.Services().Storage().V1().Bucket() listRuleBucket, err := listRuleSvc.GetByName( ctx, &storage.GetBucketByNameRequest{ Name: "<bucket_name>", }, ) if err != nil { return err } fmt.Println(listRuleBucket)Nameto the bucket name. The response includes the rules inSpec.LifecycleConfiguration. -
Configure the rule in one of the following ways:
-
Create a bucket with a lifecycle rule:
In the code, set the following parameters:
createRuleConfig := &storage.LifecycleConfiguration{} createRuleJSON := []byte(`{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "expiration": {"days": <days>} }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }`) if err := protojson.Unmarshal( createRuleJSON, createRuleConfig, ); err != nil { return err } createRuleSvc := sdk.Services().Storage().V1().Bucket() createRuleOp, err := createRuleSvc.Create( ctx, &storage.CreateBucketRequest{ Metadata: &common.ResourceMetadata{ Name: "<bucket_name>", }, Spec: &storage.BucketSpec{ LifecycleConfiguration: createRuleConfig, }, }, ) if err != nil { return err } if _, err = createRuleOp.Wait(ctx); err != nil { return err }id: Rule ID.expiration.days: Number of days after upload before the objects expire.abortIncompleteMultipartUpload.daysAfterInitiation: Number of days after a multipart upload starts before Object Storage aborts it.Metadata.Name: Bucket name.
statustoENABLED. -
Add a rule to an existing bucket:
In the code, set
updateRuleConfig := &storage.LifecycleConfiguration{} updateRuleJSON := []byte(`{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "expiration": {"days": <days>} }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }`) if err := protojson.Unmarshal( updateRuleJSON, updateRuleConfig, ); err != nil { return err } updateRuleSvc := sdk.Services().Storage().V1().Bucket() updateRuleBucket, err := updateRuleSvc.Get( ctx, &storage.GetBucketRequest{ Id: "<bucket_ID>", }, ) if err != nil { return err } updateRuleBucket.Spec.LifecycleConfiguration = updateRuleConfig updateRuleOp, err := updateRuleSvc.Update( ctx, &storage.UpdateBucketRequest{ Metadata: updateRuleBucket.Metadata, Spec: updateRuleBucket.Spec, }, ) if err != nil { return err } if _, err = updateRuleOp.Wait(ctx); err != nil { return err }id,expiration.days, andabortIncompleteMultipartUpload.daysAfterInitiationas in the create example, and setIdto the bucket ID. List every lifecycle rule in the JSON, including rules that you do not change. Otherwise, Object Storage deletes the omitted rules.
-
Create a bucket with a lifecycle rule:
To create an expiration lifecycle rule:
-
If you update an existing bucket, get its current lifecycle rules:
In the code, set
list_rule_service = BucketServiceClient(sdk) list_rule_bucket = await list_rule_service.get_by_name( GetBucketByNameRequest(name="<bucket_name>"), ) print(list_rule_bucket)nameto the bucket name. The response includes the rules inspec.lifecycle_configuration. -
Configure the rule in one of the following ways:
-
Create a bucket with a lifecycle rule:
In the code, set the following parameters:
create_rule_config = LifecycleConfiguration.from_json( """{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "expiration": {"days": <days>} }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }""", ) create_rule_service = BucketServiceClient(sdk) create_rule_operation = await create_rule_service.create( CreateBucketRequest( metadata=ResourceMetadata( name="<bucket_name>", ), spec=BucketSpec( lifecycle_configuration=create_rule_config, ), ), ) await create_rule_operation.wait()id: Rule ID.expiration.days: Number of days after upload before the objects expire.abortIncompleteMultipartUpload.daysAfterInitiation: Number of days after a multipart upload starts before Object Storage aborts it.metadata.name: Bucket name.
statustoENABLED. -
Add a rule to an existing bucket:
In the code, set
update_rule_config = LifecycleConfiguration.from_json( """{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "expiration": {"days": <days>} }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }""", ) update_rule_service = BucketServiceClient(sdk) update_rule_bucket = await update_rule_service.get( GetBucketRequest(id="<bucket_ID>"), ) update_rule_bucket.spec.lifecycle_configuration = update_rule_config update_rule_operation = await update_rule_service.update( UpdateBucketRequest( metadata=update_rule_bucket.metadata, spec=update_rule_bucket.spec, ), ) await update_rule_operation.wait()id,expiration.days, andabortIncompleteMultipartUpload.daysAfterInitiationin the rule JSON as in the create example. SetidinGetBucketRequestto the bucket ID. List every lifecycle rule in the JSON, including rules that you do not change. Otherwise, Object Storage deletes the omitted rules.
-
Create a bucket with a lifecycle rule:
To create an expiration lifecycle rule:
-
If you update an existing bucket, get its current lifecycle rules:
In the code, set
const listRuleService = new BucketService(sdk); const listRuleBucket = await listRuleService.getByName( GetBucketByNameRequest.create({ name: "<bucket_name>", }), ).result; console.log(listRuleBucket);nameto the bucket name. The response includes the rules inspec.lifecycleConfiguration. -
Configure the rule in one of the following ways:
-
Create a bucket with a lifecycle rule:
In the code, set the following parameters:
const createRuleConfig = LifecycleConfiguration.fromJSON( JSON.parse(`{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "expiration": {"days": <days>} }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }`), ); const createRuleService = new BucketService(sdk); const createRuleOperation = await createRuleService.create( CreateBucketRequest.create({ metadata: ResourceMetadata.create({ name: "<bucket_name>", }), spec: BucketSpec.create({ lifecycleConfiguration: createRuleConfig, }), }), ).result; await createRuleOperation.wait();id: Rule ID.expiration.days: Number of days after upload before the objects expire.abortIncompleteMultipartUpload.daysAfterInitiation: Number of days after a multipart upload starts before Object Storage aborts it.metadata.name: Bucket name.
statustoENABLED. -
Add a rule to an existing bucket:
In the code, set
const updateRuleConfig = LifecycleConfiguration.fromJSON( JSON.parse(`{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "expiration": {"days": <days>} }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }`), ); const updateRuleService = new BucketService(sdk); const updateRuleBucket = await updateRuleService.get( GetBucketRequest.create({ id: "<bucket_ID>" }), ).result; updateRuleBucket.spec.lifecycleConfiguration = updateRuleConfig; const updateRuleOperation = await updateRuleService.update( UpdateBucketRequest.create({ metadata: updateRuleBucket.metadata, spec: updateRuleBucket.spec, }), ).result; await updateRuleOperation.wait();id,expiration.days, andabortIncompleteMultipartUpload.daysAfterInitiationin the rule JSON as in the create example. SetidinGetBucketRequestto the bucket ID. List every lifecycle rule in the JSON, including rules that you do not change. Otherwise, Object Storage deletes the omitted rules.
-
Create a bucket with a lifecycle rule:
How to configure transition lifecycle rules
Before you configure a transition rule, check your quotas in the project. Make sure that they are sufficient for switching a storage class.
- Web console
- Nebius AI Cloud CLI
- Terraform
- AWS CLI
- Go SDK
- Python SDK
- JavaScript SDK
In the web console, you can only add lifecycle rules to existing buckets. You cannot create a bucket with a lifecycle rule.To add a transition lifecycle rule to a bucket:
-
In the web console, go to
Storage → Object Storage.
- Open the page of the required bucket.
- Go to the Lifecycle rules tab.
-
Click
Add rule.
- (Optional) On the page that opens, specify the rule name. It helps identify the rule in a list of lifecycle rules.
-
Specify which objects the rule applies to:
-
Object key prefix: The rule applies to objects whose names begin with a specified prefix. For instance, if you set the
expiring/prefix, the rule applies to theexpiring/test.txtobject and doesn’t apply to thetest.txtobject. - Minimum size, bytes: The rule applies to objects larger than the specified size.
- Maximum size, bytes: The rule applies to objects smaller than the specified size. If you set both a minimum and maximum size, make sure that the maximum size is greater than or equal to the minimum one.
- Tags: The rule applies to objects with the specified tags. A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation.
-
Object key prefix: The rule applies to objects whose names begin with a specified prefix. For instance, if you set the
- To create a transition lifecycle rule, enable the Modify storage class action.
-
Select the rule type:
- Upload: Set the number of days after the object upload. When this period expires, the storage class of the object changes.
-
Last access: Set the number of days after the last access to the object. When this period expires, the storage class changes.
You can set filters to define what actions are considered the last access to the object. These filters apply to all last-access lifecycle rules.
- Date: Set a specific date when you need to switch the storage class.
- Select a new storage class that the lifecycle rule applies to.
- Click Add rule.
When you update the settings of a bucket, make sure to list all lifecycle rules, even the ones that you do not change. If you do not include some rules, Object Storage will delete them.When you reconfigure a rule, specify only the parameters that you want to change. For example, if you earlier set a filter of objects in a rule and you want to change an expiration condition, specify only the condition, and the rule name or ID. You do not need to set the filter again as it will be preserved.To create a transition lifecycle rule:
- Install and configure the Nebius AI Cloud CLI.
-
If you update the settings of an existing bucket, get a list of its lifecycle rules:
The rules are specified in the
nebius storage bucket get-by-name --name <bucket_name>spec.lifecycle_configuration.rulesparameter. If you want to preserve them when adding a new rule, duplicate those rules in theupdatecommand. -
To configure a new transition lifecycle rule, run one of the following commands:
-
Create a bucket with a lifecycle rule:
nebius storage bucket create --name <bucket_name> \ --default-storage-class <standard|enhanced_throughput|intelligent> \ --lifecycle-configuration-rules '[ { "id": "<rule_ID>", "status": "enabled", "transition": { "storage_class": "<standard|enhanced_throughput|intelligent>", "days": <number_of_days> }, "filter": { <filters> } }, { <rules_created_earlier> }, ... ]' -
Add a rule to an existing bucket:
nebius storage bucket update --id <bucket_ID> \ --lifecycle-configuration-rules '[ { "id": "<rule_ID>", "status": "enabled", "transition": { "storage_class": "<standard|enhanced_throughput|intelligent>", "days": <number_of_days> }, "filter": { <filters> } }, { <rules_created_earlier> }, ... ]'
-
--name: Bucket name. -
--id: Bucket ID. To get it, runnebius storage bucket get-by-name --name <bucket_name>. -
--default-storage-class: Default storage class. It applies to objects if a storage class isn’t explicitly set for them during the upload. -
--lifecycle-configuration-rules: List of lifecycle rules. Every rule contains the following parameters:-
id: Rule ID (string). Helps identify the rule in the list of lifecycle rules. -
status: Whether the rule is enabled or disabled. Use thedisabledstatus to turn the rule off but preserve it in the list. -
transition: Conditions for a transition lifecycle rule. To change a storage class, set thestorage_classparameter. Use either thedaysordays_since_last_accessparameter:-
storage_class: New storage class. -
days: The rule applies the specified number of days after the object upload. -
days_since_last_access: The rule applies the specified number of days after the object hasn’t been accessed. The service considers an object to be accessed if its data was retrieved or copied by using S3 methods, such asGetObject,HeadObject,GetObjectTagging,CopyObject, orUploadPartCopy. You can configure the rule to refer only to some of these methods by using last access filters.
-
-
filter(optional): Filters of objects. By using them, you can apply a rule to certain objects only. You can combine the filters if needed. The available filters are the following:-
To transition objects whose names begin with a certain prefix, specify:
For instance, if you set the
"filter": { "prefix": "expiring/" }expiring/prefix, the storage class of theexpiring/test.txtobject will be switched. However, this will not happen to thetest.txtobject. -
To transition objects that exceed 5120 bytes:
"filter": { "object_size_greater_than_bytes": 5120 } -
To transition objects that are less than 128 bytes:
"filter": { "object_size_less_than_bytes": 128 } -
To transition objects with certain tags, specify:
A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation.
"filter": { "tags": [ {"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"} ] }
-
To transition objects whose names begin with a certain prefix, specify:
-
-
Create a bucket with a lifecycle rule:
To create a transition lifecycle rule:
- Install and configure the Nebius AI Cloud provider for Terraform.
-
Create a bucket with transition lifecycle rules by using the following configuration file:
The file contains the following parameters:
resource "nebius_storage_v1_bucket" "<bucket_name>" { name = "<bucket_name>" parent_id = "<project_ID>" default_storage_class = "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>" versioning_policy = "ENABLED" lifecycle_configuration = { rules = [ { id = "<rule_ID>" status = "ENABLED" transition = { storage_class = "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>" days = <number_of_days> days_since_last_access = <number_of_days> } filter = { <filters> } } ] } }-
name: Bucket name. -
parent_id: Project ID. -
default_storage_class: Default storage class. It applies to objects if a storage class isn’t explicitly set for them during the upload. -
versioning_policy: Enables versioning of objects in the bucket. For more information, see Object versioning in a bucket. -
lifecycle_configuration.rules: List of lifecycle rules. Every rule contains the following parameters:-
id: Rule ID (string). Helps identify the rule in the list of lifecycle rules. -
status: Whether the rule is enabled or disabled. Use theDISABLEDstatus to turn the rule off but preserve it in the list. -
transition: Conditions for a transition lifecycle rule. To change a storage class, set thestorage_classparameter. Use either thedaysordays_since_last_accessparameter:-
storage_class: New storage class. -
days: The rule applies the specified number of days after the object upload. -
days_since_last_access: The rule applies the specified number of days after the object hasn’t been accessed. The service considers an object to be accessed if its data was retrieved or copied by using S3 methods, such asGetObject,HeadObject,GetObjectTagging,CopyObject, orUploadPartCopy. You can configure the rule to refer only to some of these methods by using last access filters.
-
-
filter(optional): Filters of objects. By using them, you can apply a rule to certain objects only. You can combine the filters if needed. The available filters are the following:-
To transition objects whose names begin with a certain prefix, specify:
For instance, if you set the
filter = { prefix = "expiring/" }expiring/prefix, the storage class of theexpiring/test.txtobject will be switched. However, this will not happen to thetest.txtobject. -
To transition objects that exceed 5120 bytes:
filter = { object_size_greater_than_bytes = 5120 } -
To transition objects that are less than 128 bytes:
filter = { object_size_less_than_bytes = 128 } -
To transition objects with certain tags, specify:
A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation.
filter = { tags = [{"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"}] }
-
To transition objects whose names begin with a certain prefix, specify:
-
-
-
Check that the configuration is correct:
terraform validate -
Apply the changes:
terraform apply
When you update the lifecycle configuration of a bucket, make sure to list all lifecycle rules and their configuration details, even the ones that you don’t change. If you don’t include some of them, the service will remove and replace them with the last lifecycle configuration.The AWS CLI only supports transition lifecycle rules that set a number of days after the object upload. If you want to set the last access time of the object or the date of the storage class switch, use the Nebius AI Cloud interfaces.Although the AWS CLI allows multiple transition actions in a single rule, Object Storage only supports one transition action per rule. If you need multiple transition actions, create multiple rules.To create a transition lifecycle rule:
- Install and configure the AWS CLI.
-
If you update the lifecycle configuration of an existing bucket, get its current lifecycle configuration:
The rules are specified in the
aws s3api get-bucket-lifecycle-configuration --bucket <bucket_name>Rulesparameter. If you want to preserve them when adding a new rule, duplicate those rules in the new JSON file that you apply to the bucket. -
To configure a new transition lifecycle rule, create the
lifecycle.jsonfile with lifecycle rules:If the{ "Rules": [ { "ID": "<rule_ID>", "Status": "Enabled", "Filter": {}, "Transitions": [ { "StorageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "Days": <number_of_days> } ] }, { <rules_created_earlier> }, ... ] }Filterelement is left empty, the rule applies to all objects in the bucket. -
Apply the lifecycle configuration to the bucket:
Every rule contains the following parameters:
aws s3api put-bucket-lifecycle-configuration \ --bucket <bucket_name> \ --lifecycle-configuration file://lifecycle.json-
ID: Rule ID (string). Helps identify the rule in the list of lifecycle rules. -
Status: Whether the rule is enabled or disabled. Use theDisabledstatus to turn the rule off but preserve it in the list. -
Transitions: Conditions for a transition lifecycle rule. To change a storage class, set theStorageClassparameter. To define when the rule applies after the object upload, set theDaysparameter.StorageClass: New storage class.Days: The rule applies the specified number of days after the object upload.
-
Filter(optional): Filters of objects. By using them, you can apply a rule to certain objects only. AFiltercan contain exactly one ofPrefix,ObjectSizeGreaterThan,ObjectSizeLessThan, orAnd. To combine multiple conditions, useAnd.-
To transition objects whose names begin with a certain prefix, specify:
For instance, if you set the
"Filter": { "Prefix": "expiring/" }expiring/prefix, the storage class of theexpiring/test.txtobject will be switched. However, this will not happen to thetest.txtobject. -
To transition objects that exceed 5120 bytes, specify:
"Filter": { "ObjectSizeGreaterThan": 5120 } -
To transition objects that are less than 128 bytes, specify:
"Filter": { "ObjectSizeLessThan": 128 } -
To transition objects with a certain tag, specify:
A tag represents a key-value pair that you add to existing objects or when you upload objects. For more information, see AWS documentation. If you want to set several tags, specify:
"Filter": { "Tag": { "Key": "key1", "Value": "value1"} }"Filter": { "And": { "Tags": [{"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"}] } }
-
To transition objects whose names begin with a certain prefix, specify:
-
To create a transition lifecycle rule:
-
If you update an existing bucket, get its current lifecycle rules:
In the code, set
listRuleSvc := sdk.Services().Storage().V1().Bucket() listRuleBucket, err := listRuleSvc.GetByName( ctx, &storage.GetBucketByNameRequest{ Name: "<bucket_name>", }, ) if err != nil { return err } fmt.Println(listRuleBucket)Nameto the bucket name. The response includes the rules inSpec.LifecycleConfiguration. -
Configure the rule in one of the following ways:
-
Create a bucket with a transition lifecycle rule:
In the code, set the following parameters:
transitionSpec := &storage.BucketSpec{} transitionJSON := []byte(`{ "defaultStorageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "lifecycleConfiguration": { "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "transition": { "storageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "days": <number_of_days> }, "filter": { "objectSizeLessThanBytes": <number_of_bytes> } }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] } }`) if err := protojson.Unmarshal( transitionJSON, transitionSpec, ); err != nil { return err } createTransitionSvc := sdk.Services().Storage().V1().Bucket() createTransitionOp, err := createTransitionSvc.Create( ctx, &storage.CreateBucketRequest{ Metadata: &common.ResourceMetadata{ Name: "<bucket_name>", }, Spec: transitionSpec, }, ) if err != nil { return err } if _, err = createTransitionOp.Wait(ctx); err != nil { return err }defaultStorageClass: Default storage class for objects uploaded without an explicit storage class.id: Rule ID.transition.storageClass: Storage class to switch objects to.transition.days: Number of days after upload before the storage class changes.filter.objectSizeLessThanBytes: Maximum object size, in bytes. The rule applies to smaller objects.abortIncompleteMultipartUpload.daysAfterInitiation: Number of days after a multipart upload starts before Object Storage aborts it.Metadata.Name: Bucket name.
statustoENABLED. -
Add a rule to an existing bucket:
In the code, set
addTransitionConfig := &storage.LifecycleConfiguration{} addTransitionJSON := []byte(`{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "transition": { "storageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "days": <number_of_days> }, "filter": { "objectSizeLessThanBytes": <number_of_bytes> } }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }`) if err := protojson.Unmarshal( addTransitionJSON, addTransitionConfig, ); err != nil { return err } addTransitionSvc := sdk.Services().Storage().V1().Bucket() addTransitionBucket, err := addTransitionSvc.Get( ctx, &storage.GetBucketRequest{ Id: "<bucket_ID>", }, ) if err != nil { return err } addTransitionBucket.Spec.LifecycleConfiguration = addTransitionConfig addTransitionOp, err := addTransitionSvc.Update( ctx, &storage.UpdateBucketRequest{ Metadata: addTransitionBucket.Metadata, Spec: addTransitionBucket.Spec, }, ) if err != nil { return err } if _, err = addTransitionOp.Wait(ctx); err != nil { return err }id,transition.storageClass,transition.days,filter.objectSizeLessThanBytes, andabortIncompleteMultipartUpload.daysAfterInitiationas in the create example, and setIdto the bucket ID. List every lifecycle rule in the JSON, including rules that you do not change. Otherwise, Object Storage deletes the omitted rules.
-
Create a bucket with a transition lifecycle rule:
To create a transition lifecycle rule:
-
If you update an existing bucket, get its current lifecycle rules:
In the code, set
list_rule_service = BucketServiceClient(sdk) list_rule_bucket = await list_rule_service.get_by_name( GetBucketByNameRequest(name="<bucket_name>"), ) print(list_rule_bucket)nameto the bucket name. The response includes the rules inspec.lifecycle_configuration. -
Configure the rule in one of the following ways:
-
Create a bucket with a transition lifecycle rule:
In the code, set the following parameters:
transition_spec = BucketSpec.from_json( """{ "defaultStorageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "lifecycleConfiguration": { "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "transition": { "storageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "days": <number_of_days> }, "filter": { "objectSizeLessThanBytes": <number_of_bytes> } }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] } }""", ) create_transition_service = BucketServiceClient(sdk) create_transition_operation = await create_transition_service.create( CreateBucketRequest( metadata=ResourceMetadata( name="<bucket_name>", ), spec=transition_spec, ), ) await create_transition_operation.wait()defaultStorageClass: Default storage class for objects uploaded without an explicit storage class.id: Rule ID.transition.storageClass: Storage class to switch objects to.transition.days: Number of days after upload before the storage class changes.filter.objectSizeLessThanBytes: Maximum object size, in bytes. The rule applies to smaller objects.abortIncompleteMultipartUpload.daysAfterInitiation: Number of days after a multipart upload starts before Object Storage aborts it.metadata.name: Bucket name.
statustoENABLED. -
Add a rule to an existing bucket:
In the code, set
add_transition_config = LifecycleConfiguration.from_json( """{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "transition": { "storageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "days": <number_of_days> }, "filter": { "objectSizeLessThanBytes": <number_of_bytes> } }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }""", ) add_transition_service = BucketServiceClient(sdk) add_transition_bucket = await add_transition_service.get( GetBucketRequest(id="<bucket_ID>"), ) add_transition_bucket.spec.lifecycle_configuration = ( add_transition_config ) add_transition_operation = await add_transition_service.update( UpdateBucketRequest( metadata=add_transition_bucket.metadata, spec=add_transition_bucket.spec, ), ) await add_transition_operation.wait()id,transition.storageClass,transition.days,filter.objectSizeLessThanBytes, andabortIncompleteMultipartUpload.daysAfterInitiationin the rule JSON as in the create example. SetidinGetBucketRequestto the bucket ID. List every lifecycle rule in the JSON, including rules that you do not change. Otherwise, Object Storage deletes the omitted rules.
-
Create a bucket with a transition lifecycle rule:
To create a transition lifecycle rule:
-
If you update an existing bucket, get its current lifecycle rules:
In the code, set
const listRuleService = new BucketService(sdk); const listRuleBucket = await listRuleService.getByName( GetBucketByNameRequest.create({ name: "<bucket_name>", }), ).result; console.log(listRuleBucket);nameto the bucket name. The response includes the rules inspec.lifecycleConfiguration. -
Configure the rule in one of the following ways:
-
Create a bucket with a transition lifecycle rule:
In the code, set the following parameters:
const transitionSpec = BucketSpec.fromJSON( JSON.parse(`{ "defaultStorageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "lifecycleConfiguration": { "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "transition": { "storageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "days": <number_of_days> }, "filter": { "objectSizeLessThanBytes": <number_of_bytes> } }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] } }`), ); const createTransitionSvc = new BucketService(sdk); const createTransitionOp = await createTransitionSvc.create( CreateBucketRequest.create({ metadata: ResourceMetadata.create({ name: "<bucket_name>", }), spec: transitionSpec, }), ).result; await createTransitionOp.wait();defaultStorageClass: Default storage class for objects uploaded without an explicit storage class.id: Rule ID.transition.storageClass: Storage class to switch objects to.transition.days: Number of days after upload before the storage class changes.filter.objectSizeLessThanBytes: Maximum object size, in bytes. The rule applies to smaller objects.abortIncompleteMultipartUpload.daysAfterInitiation: Number of days after a multipart upload starts before Object Storage aborts it.metadata.name: Bucket name.
statustoENABLED. -
Add a rule to an existing bucket:
In the code, set
const addTransitionConfig = LifecycleConfiguration.fromJSON( JSON.parse(`{ "rules": [ { "id": "<rule_ID>", "status": "ENABLED", "transition": { "storageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>", "days": <number_of_days> }, "filter": { "objectSizeLessThanBytes": <number_of_bytes> } }, { "id": "<rule_ID>", "status": "ENABLED", "abortIncompleteMultipartUpload": { "daysAfterInitiation": <days> } }, ... ] }`), ); const addTransitionSvc = new BucketService(sdk); const addTransitionBucket = await addTransitionSvc.get( GetBucketRequest.create({ id: "<bucket_ID>" }), ).result; addTransitionBucket.spec.lifecycleConfiguration = addTransitionConfig; const addTransitionOp = await addTransitionSvc.update( UpdateBucketRequest.create({ metadata: addTransitionBucket.metadata, spec: addTransitionBucket.spec, }), ).result; await addTransitionOp.wait();id,transition.storageClass,transition.days,filter.objectSizeLessThanBytes, andabortIncompleteMultipartUpload.daysAfterInitiationin the rule JSON as in the create example. SetidinGetBucketRequestto the bucket ID. List every lifecycle rule in the JSON, including rules that you do not change. Otherwise, Object Storage deletes the omitted rules.
-
Create a bucket with a transition lifecycle rule:
(Optional) Filters for last-access lifecycle rules
You can filter actions that Object Storage considers or ignores when it determines the timestamp of the object’s last access. In the filters, specify S3 methods and user agents (such asrclone) that should be included or excluded.
Filters apply to all last-access lifecycle rules. You configure them at the bucket level.
By default, no filters apply. All and user agents are included.
- Web console
- Nebius AI Cloud CLI
- Terraform
- Go SDK
- Python SDK
- JavaScript SDK
-
In the web console, go to
Storage → Object Storage.
- Open the page of the required bucket.
- Go to the Settings tab.
-
In the Filters for last-access lifecycle rules section, click
Add filter.
-
In the Filter type field, select one of the following:
Include: Consider only the methods and user agents listed in the filter.Exclude: Ignore the methods and user agents listed.
-
Specify the S3 methods and user agents for the filter. Among the S3 methods, you can set
GetObject,HeadObject,GetObjectTagging,CopyObject, andUploadPartCopy. If you don’t specify methods or user agents, Object Storage considers all of them. - Click Add filter. The new filter appears in the list of filters for last-access lifecycle rules.
- Click Save changes to confirm.
When you create or update a bucket, set the filters by using the
--lifecycle-configuration-last-access-filter-conditions parameter.-
Create a bucket with a lifecycle rule:
nebius storage bucket create --name <bucket_name> \ --default-storage-class <standard|enhanced_throughput|intelligent> \ --lifecycle-configuration-rules '[...]' \ --lifecycle-configuration-last-access-filter-conditions '[ { "type": "<include|exclude>", "methods": ["<S3_methods>"], "user_agents": ["<user_agents>"] }, { <other_conditions> }, ... ]' -
Add a rule to an existing bucket:
nebius storage bucket update --id <bucket_ID> \ --lifecycle-configuration-rules '[...]' \ --lifecycle-configuration-last-access-filter-conditions '[ { "type": "<include|exclude>", "methods": ["<S3_methods>"], "user_agents": ["<user_agents>"] }, { <other_conditions> }, ... ]'
GetObject and CopyObject methods were executed by using the rclone user agent. Alternatively, the service can ignore the GetObject and UploadPartCopy methods.Every filter contains the following fields:-
type: Whether listed S3 methods and user agents should be considered to determine if the object is accessed. Possible values are the following:INCLUDE: Consider only the methods and user agents listed in the filter.EXCLUDE: Ignore the methods and user agents listed.
-
methods: List of S3 methods, such as"GET_OBJECT","HEAD_OBJECT","GET_OBJECT_TAGGING","COPY_OBJECT"and"UPLOAD_PART_COPY". If you do not specify themethodsparameter, Object Storage considers all methods. -
user_agents: List of substrings that user agents (clients addressing an object) can contain. For instance, if you specifyrclone, only the user agents with therclonesubstring trigger the countdown of days for the rule to apply. If you do not specify theuser_agentsparameter, Object Storage considers all user agents.
methods or user_agents. You can use both of them as well, but you cannot use a filter with the type parameter only.When you create or update a bucket, set the filters by using the Apply the filtering parameter only if you use the transition.days_since_last_access parameter.For example, the service can consider an object to be accessed only if the
last_access_filter.conditions parameter.resource "nebius_storage_v1_bucket" "<bucket_name>" {
...
lifecycle_configuration = {
rules = [...]
last_access_filter = [
{
conditions = [
{
type = "<INCLUDE|EXCLUDE>"
methods = ["<S3_methods>"]
user_agents = ["<user_agents>"]
},
{
<other_conditions>
},
...
]
}
]
}
}
GetObject and CopyObject methods were executed by using the rclone user agent. Alternatively, the service can ignore the GetObject and UploadPartCopy methods.Every filter contains the following fields:-
type: Whether listed S3 methods and user agents should be considered to determine if the object is accessed. Possible values are the following:INCLUDE: Consider only the methods and user agents listed in the filter.EXCLUDE: Ignore the methods and user agents listed.
-
methods: List of S3 methods, such as"GET_OBJECT","HEAD_OBJECT","GET_OBJECT_TAGGING","COPY_OBJECT"and"UPLOAD_PART_COPY". If you do not specify themethodsparameter, Object Storage considers all methods. -
user_agents: List of substrings that user agents (clients addressing an object) can contain. For instance, if you specifyrclone, only the user agents with therclonesubstring trigger the countdown of days for the rule to apply. If you do not specify theuser_agentsparameter, Object Storage considers all user agents.
methods or user_agents. You can use both of them as well, but you cannot use a filter with the type parameter only.Create a bucket with last-access filters:In the code, set the following parameters:In the code, set the same filter parameters, and set
filterSpec := &storage.BucketSpec{}
filterJSON := []byte(`{
"defaultStorageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>",
"lifecycleConfiguration": {
"rules": [...],
"lastAccessFilter": {
"conditions": [
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
...
]
}
}
}`)
if err := protojson.Unmarshal(
filterJSON,
filterSpec,
); err != nil {
return err
}
createFilterSvc := sdk.Services().Storage().V1().Bucket()
createFilterOp, err := createFilterSvc.Create(
ctx,
&storage.CreateBucketRequest{
Metadata: &common.ResourceMetadata{
Name: "<bucket_name>",
},
Spec: filterSpec,
},
)
if err != nil {
return err
}
if _, err = createFilterOp.Wait(ctx); err != nil {
return err
}
defaultStorageClass: Default storage class for objects uploaded without an explicit storage class.type:INCLUDEto count only the listed methods and user agents, orEXCLUDEto ignore them.methods: S3 methods that count as access, such asGET_OBJECT.userAgents: Substrings of user agents that count as access.Metadata.Name: Bucket name.
updateFilterConfig := &storage.LifecycleConfiguration{}
updateFilterJSON := []byte(`{
"rules": [...],
"lastAccessFilter": {
"conditions": [
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
...
]
}
}`)
if err := protojson.Unmarshal(
updateFilterJSON,
updateFilterConfig,
); err != nil {
return err
}
updateFilterSvc := sdk.Services().Storage().V1().Bucket()
updateFilterBucket, err := updateFilterSvc.Get(
ctx,
&storage.GetBucketRequest{
Id: "<bucket_ID>",
},
)
if err != nil {
return err
}
updateFilterBucket.Spec.LifecycleConfiguration =
updateFilterConfig
updateFilterOp, err := updateFilterSvc.Update(
ctx,
&storage.UpdateBucketRequest{
Metadata: updateFilterBucket.Metadata,
Spec: updateFilterBucket.Spec,
},
)
if err != nil {
return err
}
if _, err = updateFilterOp.Wait(ctx); err != nil {
return err
}
Id to the bucket ID. Keep the existing lifecycle rules in rules.Create a bucket with last-access filters:In the code, set the following parameters:In the code, set the same filter parameters. Set
filter_spec = BucketSpec.from_json(
"""{
"defaultStorageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>",
"lifecycleConfiguration": {
"rules": [...],
"lastAccessFilter": {
"conditions": [
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
...
]
}
}
}""",
)
create_filter_service = BucketServiceClient(sdk)
create_filter_operation = await create_filter_service.create(
CreateBucketRequest(
metadata=ResourceMetadata(
name="<bucket_name>",
),
spec=filter_spec,
),
)
await create_filter_operation.wait()
defaultStorageClass: Default storage class for objects uploaded without an explicit storage class.type:INCLUDEto count only the listed methods and user agents, orEXCLUDEto ignore them.methods: S3 methods that count as access, such asGET_OBJECT.userAgents: Substrings of user agents that count as access.metadata.name: Bucket name.
update_filter_config = LifecycleConfiguration.from_json(
"""{
"rules": [...],
"lastAccessFilter": {
"conditions": [
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
...
]
}
}""",
)
update_filter_service = BucketServiceClient(sdk)
update_filter_bucket = await update_filter_service.get(
GetBucketRequest(id="<bucket_ID>"),
)
update_filter_bucket.spec.lifecycle_configuration = (
update_filter_config
)
update_filter_operation = await update_filter_service.update(
UpdateBucketRequest(
metadata=update_filter_bucket.metadata,
spec=update_filter_bucket.spec,
),
)
await update_filter_operation.wait()
id in GetBucketRequest to the bucket ID. Keep the existing lifecycle rules in rules.Create a bucket with last-access filters:In the code, set the following parameters:In the code, set the same filter parameters. Set
const filterSpec = BucketSpec.fromJSON(
JSON.parse(`{
"defaultStorageClass": "<STANDARD|ENHANCED_THROUGHPUT|INTELLIGENT>",
"lifecycleConfiguration": {
"rules": [...],
"lastAccessFilter": {
"conditions": [
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
...
]
}
}
}`),
);
const createFilterSvc = new BucketService(sdk);
const createFilterOp = await createFilterSvc.create(
CreateBucketRequest.create({
metadata: ResourceMetadata.create({
name: "<bucket_name>",
}),
spec: filterSpec,
}),
).result;
await createFilterOp.wait();
defaultStorageClass: Default storage class for objects uploaded without an explicit storage class.type:INCLUDEto count only the listed methods and user agents, orEXCLUDEto ignore them.methods: S3 methods that count as access, such asGET_OBJECT.userAgents: Substrings of user agents that count as access.metadata.name: Bucket name.
const updateFilterConfig = LifecycleConfiguration.fromJSON(
JSON.parse(`{
"rules": [...],
"lastAccessFilter": {
"conditions": [
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
{
"type": "<INCLUDE|EXCLUDE>",
"methods": ["<GET_OBJECT|...>"],
"userAgents": ["<user_agent>"]
},
...
]
}
}`),
);
const updateFilterSvc = new BucketService(sdk);
const updateFilterBucket = await updateFilterSvc.get(
GetBucketRequest.create({ id: "<bucket_ID>" }),
).result;
updateFilterBucket.spec.lifecycleConfiguration =
updateFilterConfig;
const updateFilterOp = await updateFilterSvc.update(
UpdateBucketRequest.create({
metadata: updateFilterBucket.metadata,
spec: updateFilterBucket.spec,
}),
).result;
await updateFilterOp.wait();
id in GetBucketRequest to the bucket ID. Keep the existing lifecycle rules in rules.Examples of transition lifecycle rules
Below are examples of how to create a bucket with a transition lifecycle rule that triggers if an object wasn’t accessed for a long time.-
Switch a storage class to Standard if the object hasn’t been accessed in seven days. For the access, don’t consider the
GetObjectandCopyObjectmethods that were made by usingrclone.- Nebius AI Cloud CLI
- Terraform
- Go SDK
- Python SDK
- JavaScript SDK
To set such a rule, run the following command:nebius storage bucket create --name my-bucket \ --default-storage-class enhanced_throughput \ --lifecycle-configuration-rules '[ { "id": "switch-to-standard-in-7-days", "status": "enabled", "transition": { "days_since_last_access": 7, "storage_class": "standard" } } ]' \ --lifecycle-configuration-last-access-filter-conditions '[ { "type": "exclude", "methods": ["get_object", "copy_object"], "user_agents": ["rclone"] } ]'To set such a rule, apply the following configuration:In the configuration, setresource "nebius_storage_v1_bucket" "switch_to_standard_7_days" { name = "my-bucket" parent_id = "<project_ID>" default_storage_class = "ENHANCED_THROUGHPUT" lifecycle_configuration = { rules = [ { id = "switch-to-standard-in-7-days" status = "ENABLED" transition = { days_since_last_access = 7 storage_class = "STANDARD" } } ] last_access_filter = [ { conditions = [ { type = "EXCLUDE" methods = ["GET_OBJECT", "COPY_OBJECT"] user_agents = ["rclone"] } ] } ] } }parent_idto the project ID.Create the bucket:In the code,sevenDaySpec := &storage.BucketSpec{} sevenDayJSON := []byte(`{ "defaultStorageClass": "ENHANCED_THROUGHPUT", "lifecycleConfiguration": { "rules": [ { "id": "switch-to-standard-in-7-days", "status": "ENABLED", "transition": { "storageClass": "STANDARD", "daysSinceLastAccess": 7 } } ], "lastAccessFilter": { "conditions": [ { "type": "EXCLUDE", "methods": [ "GET_OBJECT", "COPY_OBJECT" ], "userAgents": ["rclone"] } ] } } }`) if err := protojson.Unmarshal( sevenDayJSON, sevenDaySpec, ); err != nil { return err } createSevenDaySvc := sdk.Services().Storage().V1(). Bucket() createSevenDayOp, err := createSevenDaySvc.Create( ctx, &storage.CreateBucketRequest{ Metadata: &common.ResourceMetadata{ Name: "my-bucket", }, Spec: sevenDaySpec, }, ) if err != nil { return err } if _, err = createSevenDayOp.Wait(ctx); err != nil { return err }Metadata.Nameis the bucket name. The example usesmy-bucket.Create the bucket:In the code,seven_day_spec = BucketSpec.from_json( """{ "defaultStorageClass": "ENHANCED_THROUGHPUT", "lifecycleConfiguration": { "rules": [ { "id": "switch-to-standard-in-7-days", "status": "ENABLED", "transition": { "storageClass": "STANDARD", "daysSinceLastAccess": 7 } } ], "lastAccessFilter": { "conditions": [ { "type": "EXCLUDE", "methods": [ "GET_OBJECT", "COPY_OBJECT" ], "userAgents": ["rclone"] } ] } } }""", ) create_seven_day_service = BucketServiceClient(sdk) create_seven_day_operation = ( await create_seven_day_service.create( CreateBucketRequest( metadata=ResourceMetadata( name="my-bucket", ), spec=seven_day_spec, ), ) ) await create_seven_day_operation.wait()metadata.nameis the bucket name. The example usesmy-bucket.Create the bucket:In the code,const sevenDaySpec = BucketSpec.fromJSON( JSON.parse(`{ "defaultStorageClass": "ENHANCED_THROUGHPUT", "lifecycleConfiguration": { "rules": [ { "id": "switch-to-standard-in-7-days", "status": "ENABLED", "transition": { "storageClass": "STANDARD", "daysSinceLastAccess": 7 } } ], "lastAccessFilter": { "conditions": [ { "type": "EXCLUDE", "methods": [ "GET_OBJECT", "COPY_OBJECT" ], "userAgents": ["rclone"] } ] } } }`), ); const createSevenDaySvc = new BucketService(sdk); const createSevenDayOp = await createSevenDaySvc. create( CreateBucketRequest.create({ metadata: ResourceMetadata.create({ name: "my-bucket", }), spec: sevenDaySpec, }), ).result; await createSevenDayOp.wait();metadata.nameis the bucket name. The example usesmy-bucket. -
Switch a storage class to Standard if the object hasn’t been accessed in three days. For the access, consider only the
GetObjectTaggingmethod.- Nebius AI Cloud CLI
- Terraform
- Go SDK
- Python SDK
- JavaScript SDK
To set such a rule, run the following command:nebius storage bucket create --name my-bucket \ --default-storage-class enhanced_throughput \ --lifecycle-configuration-rules '[ { "id": "switch-to-standard-in-3-days", "status": "enabled", "transition": { "days_since_last_access": 3, "storage_class": "standard" } } ]' \ --lifecycle-configuration-last-access-filter-conditions '[ { "type": "include", "methods": ["get_object_tagging"] } ]'To set such a rule, apply the following configuration:In the configuration, setresource "nebius_storage_v1_bucket" "switch_to_standard_3_days" { name = "my-bucket" parent_id = "<project_ID>" default_storage_class = "ENHANCED_THROUGHPUT" lifecycle_configuration = { rules = [ { id = "switch-to-standard-in-3-days" status = "ENABLED" transition = { days_since_last_access = 3 storage_class = "STANDARD" } } ] last_access_filter = [ { conditions = [ { type = "INCLUDE" methods = ["GET_OBJECT_TAGGING"] } ] } ] } }parent_idto the project ID.Create the bucket:In the code,threeDaySpec := &storage.BucketSpec{} threeDayJSON := []byte(`{ "defaultStorageClass": "ENHANCED_THROUGHPUT", "lifecycleConfiguration": { "rules": [ { "id": "switch-to-standard-in-3-days", "status": "ENABLED", "transition": { "storageClass": "STANDARD", "daysSinceLastAccess": 3 } } ], "lastAccessFilter": { "conditions": [ { "type": "INCLUDE", "methods": ["GET_OBJECT_TAGGING"] } ] } } }`) if err := protojson.Unmarshal( threeDayJSON, threeDaySpec, ); err != nil { return err } createThreeDaySvc := sdk.Services().Storage().V1(). Bucket() createThreeDayOp, err := createThreeDaySvc.Create( ctx, &storage.CreateBucketRequest{ Metadata: &common.ResourceMetadata{ Name: "my-bucket", }, Spec: threeDaySpec, }, ) if err != nil { return err } if _, err = createThreeDayOp.Wait(ctx); err != nil { return err }Metadata.Nameis the bucket name. The example usesmy-bucket.Create the bucket:In the code,three_day_spec = BucketSpec.from_json( """{ "defaultStorageClass": "ENHANCED_THROUGHPUT", "lifecycleConfiguration": { "rules": [ { "id": "switch-to-standard-in-3-days", "status": "ENABLED", "transition": { "storageClass": "STANDARD", "daysSinceLastAccess": 3 } } ], "lastAccessFilter": { "conditions": [ { "type": "INCLUDE", "methods": ["GET_OBJECT_TAGGING"] } ] } } }""", ) create_three_day_service = BucketServiceClient(sdk) create_three_day_operation = ( await create_three_day_service.create( CreateBucketRequest( metadata=ResourceMetadata( name="my-bucket", ), spec=three_day_spec, ), ) ) await create_three_day_operation.wait()metadata.nameis the bucket name. The example usesmy-bucket.Create the bucket:In the code,const threeDaySpec = BucketSpec.fromJSON( JSON.parse(`{ "defaultStorageClass": "ENHANCED_THROUGHPUT", "lifecycleConfiguration": { "rules": [ { "id": "switch-to-standard-in-3-days", "status": "ENABLED", "transition": { "storageClass": "STANDARD", "daysSinceLastAccess": 3 } } ], "lastAccessFilter": { "conditions": [ { "type": "INCLUDE", "methods": ["GET_OBJECT_TAGGING"] } ] } } }`), ); const createThreeDaySvc = new BucketService(sdk); const createThreeDayOp = await createThreeDaySvc. create( CreateBucketRequest.create({ metadata: ResourceMetadata.create({ name: "my-bucket", }), spec: threeDaySpec, }), ).result; await createThreeDayOp.wait();metadata.nameis the bucket name. The example usesmy-bucket.