Updated on 2024-10-24 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 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 and the new rule then automatically overwrites the existing one. For details, see Configuring a Lifecycle Rule on OBS Console.

Lifecycle Rule Configuration

You can configure lifecycle rules by using OBS Console, APIs, or SDKs.

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 the deletion time for each version of object 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.

OBS allows you to use only APIs and SDKs to set the lifecycle rule for an object.