Updated on 2026-08-21 GMT+08:00

Creating a Lifecycle Rule

Application Scenarios

This section describes how to create a lifecycle rule.

Constraints

  • A lifecycle rule can use prefixes and object tags as filters, but it cannot use wildcards, suffixes, or regular expressions.
  • A bucket can have an unlimited number of lifecycle rules, but the XML file of all its rules cannot exceed 20 KB.
  • A maximum of 20 lifecycle rules can be configured for a parallel file system.
  • Lifecycle configuration uses overwrite semantics. When you update a bucket's lifecycle configuration, you must include both the existing rules and any new rules in the updated configuration. For example, if a bucket has already had Rule 1, you can add Rule 2 by performing the following operations:
    1. Call GetBucketLifecycle to obtain Rule 1.
    2. Add Rule 2.
    3. Call PutBucketLifecycle to update the lifecycle rule to Rule 1 and Rule 2.

    If you use OBS Console to update an existing lifecycle rule, you do not need to obtain the rule first. You just need to add a new rule. The new rule automatically overwrites the existing one. For details, see Configuring a Lifecycle Rule on OBS Console.

Lifecycle Rule Configuration

You can use OBS Console, APIs, or SDKs to configure a lifecycle rule.

Configuring a Lifecycle Rule for a Single Object

You can set the time for deleting an object when uploading it. If versioning is enabled, you can set a deletion time for each object version when uploading it. An object lifecycle rule only affects object versions and not delete markers or fragments.

Unlike configuring a lifecycle rule for a bucket, an object lifecycle rule applies only to that specific object. You can schedule the deletion of the object, but storage class transitions are not supported for individual objects. If a bucket lifecycle rule conflicts with an object lifecycle rule, the object lifecycle rule applies.

You can use APIs or SDKs to configure and view object lifecycle rules. You cannot use OBS Console, OBS Browser+, or obsutil to do so.