---
title: Managing the lifecycle of objects
description: Use the API to manage lifecycle rules in Scaleway Object Storage.
tags: object storage object-storage lifecycle
dates:
  validation: 2026-03-31
  posted: 2019-05-14
---
import Requirements from '@macros/iam/requirements.mdx'
import LifecycleMinimalDurationMessage from '@macros/object-storage/lifecycle-minimal-duration-message.mdx'

You can configure the lifecycle of a group of objects to manage their storage costs effectively. A lifecycle configuration is a set of rules that defines actions applied to a group of objects stored on Object Storage.

The Amazon S3 API allows you to automatically manage the lifecycle of your object by setting lifecycle rules. These rules allow you to automatically:
  - Transition objects and their versions to a colder storage class
  - Delete your objects and their versions by setting expiration durations
  - Abort incomplete [multipart uploads](/object-storage/api-cli/multipart-uploads/)
  - Expire delete markers without a non-current version automatically

<LifecycleMinimalDurationMessage />

Lifecycle management on Object Storage is available on every Amazon S3 compliant tool (sdk, aws-cli, boto, etc), as well as from the Scaleway [console](/object-storage/how-to/manage-lifecycle-rules/).

<Requirements />

- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- An [Object Storage bucket](/object-storage/how-to/create-a-bucket/)
- Installed and initialized the [AWS CLI](/object-storage/api-cli/object-storage-aws-cli/)

## Creating a lifecycle rule using the AWS CLI

1. Create a new `my-lifecycle-rule.json` file.

2. Add the required rules to it using the rule elements detailed in the [section about XML tokens](#available-xml-tokens).

    ```json
    {
      "Rules": [
        {
          "ID": "TransitionToGlacierAfter90Days",
          "Status": "Enabled",
          "Filter": { "Prefix": "" },
          "Transitions": [
            {
              "Days": 90,
              "StorageClass": "GLACIER"
            }
          ]
        }
      ]
    }
    ```

3. Run the following command to apply the lifecycle rule to the specified bucket. Do not forget to replace the placeholders with the appropriate values.

    ```bash
    aws s3api put-bucket-lifecycle-configuration \
    --bucket my-bucket \
    --lifecycle-configuration file://my-lifecycle-rule.json
    ```

    No output is returned.

4. Run the following command to make sure the rule was properly applied:

    ```bash
    aws s3api get-bucket-lifecycle-configuration \
    --bucket my-bucket \
    ```

    The content of your rules displays.

<Message type="note">
You can view active rules in the **Lifecycle rules** tab of your bucket in the [Scaleway console](https://console.scaleway.com/).
</Message>

## Lifecycle specification

A lifecycle configuration is an XML file, containing a set of rules with predefined actions that you want Object Storage to perform on objects during their lifetime:

```xml
<LifecycleConfiguration>
  <Rule>
  ...
  </Rule>
  <Rule>
  ...
  </Rule>
  ...
</LifecycleConfiguration>
```

Each `Rule` consists of the following:
- `Filter` identifying a subset of objects to which the rule applies.
- `Status` whether the rule is in effect (a rule can be present but `Disabled`)
- Lifecycle transition(s) to perform on the selected objects

## Available XML tokens

### Rule

**Description**
: Container for a lifecycle rule. There is a limit of one thousand (1000) rules per bucket.

**Parent**
: `LifecycleConfiguration`

### Filter

**Description**
: Container for elements that describes the subset of the object the rule applies for. If the content of the tag is empty, the rule applies to all objects in the bucket.

**Parent**
: `Rule`

### And

**Description**
: Container for chaining rule filters.

**Parent**
: `Rule`

**Sample**
```xml
<And>
  <Prefix>myprefix</Prefix>
  <Tag>
    <Key>mytagkey1</Key>
    <Value>mytagvalue1</Value>
  </Tag>
</And>
```
This applies the `Prefix` rule *and* the `Tag`.

### Prefix

**Description**
: Object key prefix identifying one or more objects to which the rule applies. Object Storage limits this token to 1 per `Filter` Rule.

**Parent**
: `Filter` or `And`

### Tag

**Description**
: Container for specifying a `Key` and a `Value`.

**Parent**
: `Filter` or `And`


### Status
**Description**
: Describes whether or not a rule is enabled.

**Parent**
: `Rule`

**Values**
: `Enabled`, `Disabled`

### Transition

**Description**
: Specifies a period and a destination for an object's lifetime

**Parent**
: `Rule`

<Message type="note">
Lifecycle rules only allow the following transitions:
- Standard Multi-AZ -> Standard One Zone 
- Standard Multi-AZ -> Glacier
- Standard One Zone -> Glacier
</Message>

### Day

**Description**
: Specifies the number of days after object creation when the rule takes effect.

**Parent**
: `Transition` and/or `Expiration`

### StorageClass
**Description**
: Specifies the storage class to which the object shall be transferred. On the Scaleway platform the storage classes `STANDARD`, `GLACIER` and `ONEZONE_IA` are available.

**Parent**
: `Transition`

### Expiration

**Description**
: Describes the expiration of the object lifetime. If versioning is enabled, this rule only deletes the current version of an object.

**Parent**
: `Rule`

### ID
**Description**
: Unique identifier for the rule. This value is limited to 255 characters.

**Parent**
: `Rule`

### ExpiredObjectDeleteMarker

**Description**
: Enables the expiration of delete markers without non-current versions. Expired delete markers are deleted automatically.

**Parent**
: `Expiration`

### NoncurrentVersionExpiration

**Description**
: Describes the lifetime of non-current versions before they expire. Expired objects are deleted automatically.

**Parent**
: `Rule`

### NoncurrentVersionTransitions

**Description**
: Describes the lifetime of non-current versions before being transitioned to the specified storage class. See [Transition](#transition) for allowed transitions.

**Parent**
: `Rule`

### NoncurrentDays

**Description**
The number of days after which non-current versions are expired or transitioned.

**Parent**
: `NoncurrentVersionTransitions`, `NoncurrentVersionExpiration`

**Configuration example**

```xml
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Rule>
    <ID>id-1</ID>
      <Expiration>
        <Days>1</Days>
      </Expiration>
    <Filter>
      <And>
        <Prefix>myprefix</Prefix>
      <Tag>
        <Key>mytagkey1</Key>
        <Value>mytagvalue1</Value>
      </Tag>
      <Tag>
        <Key>mytagkey2</Key>
        <Value>mytagvalue2</Value>
      </Tag>
      </And>
    </Filter>
    <Status>Enabled</Status>
  </Rule>
</LifecycleConfiguration>
```

The lifecycle configuration above translates to the following effective rules:

- on the rule named `id-1`, we set the objects with the `myprefix` Prefix
- the tags `mytagkey1`, `mytagkey2` sets to `mytagvalue1`
- `mytagvalue2` is set to expire after one day.

<Message type="note">
  To see examples of lifecycle rules API requests, refer to the Bucket Operations [documentation page](/object-storage/api-cli/bucket-operations/#putbucketlifecycleconfiguration).
</Message>

## Setting rules for incomplete multipart uploads

When using the `awscli` to perform a [multipart upload](/object-storage/api-cli/multipart-uploads/), it is possible to set a bucket lifecycle rule that allows you to automate the *stoppage* of uploads if they are not completed. You can define a deadline for the expected completion with a lifecycle rule. If the multipart upload is incomplete by the end of the defined timeframe, it will be stopped and the parts associated with it will be deleted.

You can automate the removal of incomplete multipart uploads by adding or uploading a lifecycle configuration to your bucket. The setup can be done via an API call or an [AWS-CLI](/object-storage/api-cli/object-storage-aws-cli/) command.

Send a [PutBucketLifecycleConfiguration](/object-storage/api-cli/bucket-operations/#putbucketlifecycleconfiguration) request with the following XML payload:

```xml no-copy
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Rule>
    <ID>Remove uncompleted uploads</ID>
    <Filter>
       <Prefix></Prefix>
    </Filter>
    <Status>Enabled</Status>
    <AbortIncompleteMultipartUpload>
         <DaysAfterInitiation>1</DaysAfterInitiation>
    </AbortIncompleteMultipartUpload>
</Rule>
</LifecycleConfiguration>
```
<Message type="note">
  In this example, the multipart upload timeframe is one day. You may change the number of `DaysAfterInitiation` according to your preference by replacing `1` in the XML payload.
</Message>

**CLI command**

1. Create a file called `incomplete-upload-lifecycle-policy.json` with the following content.
    ```json
    {
      "Rules": [{
        "ID": "Remove incomplete multipart uploads",
        "Status": "Enabled",
        "Filter": {
          "Prefix": ""
        },
        "AbortIncompleteMultipartUpload": {
          "DaysAfterInitiation": 1
        }
      }]
    }
    ```
    <Message type="note">
      In this example, the multipart upload timeframe is one day. You may change the number of `DaysAfterInitiation` according to your preference by replacing `1` in the `.json` file body.
    </Message>
2. In a terminal, run the command below to apply your lifecycle configuration to the desired bucket:

```bash
aws s3api put-bucket-lifecycle-configuration --bucket my-bucket --lifecycle-configuration file://incomplete-upload-lifecycle-policy.json
```
