Updated on 2025-11-10 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 tags but 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.
  • If you want to modify the lifecycle rules of a bucket, you need to add rules. 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 setting a lifecycle rule for a bucket, an object lifecycle rule only applies to that specific object. You can only schedule the deletion of the object, and not any storage class transitions. If a bucket lifecycle rule conflicts with an object lifecycle rule, the object lifecycle rule will apply.

You can use APIs or SDKs to configure a lifecycle rule for a single object.