> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://wiki.leviia.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Setting up S3 LifeCycles

This article gives you an easy-to-understand LifeCycle for your LEVIIA Storag3 buckets, with 3 of the most frequently used examples:

* Automatically deleting expired delete markers
* Managing obsolete versions of versioned objects
* Cleaning up incomplete multipart uploads

1. Expired delete markers:

This rule automatically cleans up expired delete markers.

A delete marker is considered expired when it is the only remaining version of an object (all other versions having been deleted).

```json
{
  "Rules": [
    {
      "ID": "LEVIIA-Supprimer-Marqueurs-Expirés",
      "Status": "Enabled",
      "Filter": {},
      "Expiration": {
        "ExpiredObjectDeleteMarker": true
      }
    }
  ]
}
```

### 2. Non-current versions (obsolete versions)

Out-of-date versions will be deleted **365** days after becoming out-of-date. In addition to the current version, the 5 most recent non-current versions will be retained, even if they exceed the 365-day period.

The values for 365 days and 5 versions can be adjusted in your JSON file to suit your needs.

```json
{
  "Rules": [
    {
      "ID": "LEVIIA-G\u00e9rer-Versions-Non-Courantes",
      "Status": "Enabled",
      "Filter": {},
      "NoncurrentVersionExpiration": {
        "NoncurrentDays": 365,
        "NewerNoncurrentVersions": 5
      }
    }
  ]
}
```

### 3. Incomplete multipart uploads

Incomplete multipart uploads will be deleted **7** days after initiation. This 7-day value can be adjusted in your JSON file to suit your needs.

```json
{
  "Rules": [
    {
      "ID": "LEVIIA-Nettoyer-Uploads-Multipart",
      "Status": "Enabled",
      "Filter": {},
      "AbortIncompleteMultipartUpload": {
        "DaysAfterInitiation": 7
      }
    }
  ]
}
```

It's also possible to combine all these rules into a single one:

# JSON example combining the 3 rules above:

```json
{
  "Rules": [
    {
      "ID": "LEVIIA-Configuration-Combinée",
      "Status": "Enabled",
      "Filter": {},
      "Expiration": {
        "ExpiredObjectDeleteMarker": true
      },
      "NoncurrentVersionExpiration": {
        "NoncurrentDays": 365,
        "NewerNoncurrentVersions": 5
      },
      "AbortIncompleteMultipartUpload": {
        "DaysAfterInitiation": 7
      }
    }
  ]
}
```

In this combined example, the lifecycle:

* Deletes expired Delete Markers

* Deletes out-of-date versions after **365** days, while always retaining the **5** latest versions, even if these are more than 365 days old.

* Delete failed MultiParts Uploads after **7** days

**Configuration anatomy for LEVIIA Storag3:**

* `Rules`: List of lifecycle rules
    
* `ID`: Unique rule identifier
    
* `Status`: Rule status (Enabled/Disabled)
    
* `Filter`: Filters to target specific objects
    
* `Expiration`: Configuration for deletion of current objects
        
* `ExpiredObjectDeleteMarker`: Deletes expired deletion markers
    
* `NoncurrentVersionExpiration`: Configuration for older versions
        
* `NoncurrentDays`: Number of days before deletion
        
* `NewNoncurrentVersions`: (optional) Minimum number of versions to keep
    
* `AbortIncompleteMultipartUpload`: Configuration for incomplete uploads
        
* `DaysAfterInitiation`: Number of days before cleanup

**Important notes**:
    
1. Lifecycle rules are executed asynchronously, so there may be a delay between configuration and actual application.
    
2. To test your rules, we recommend that you first apply the configuration to a test bucket before using it in production.
    
3. Objects protected by S3 Object Lock (immutability) will not be deleted by lifecycle rules before the end of their retention period.