# Manage S3 rules using the CLI

Using the CLI, you can:

* [Create an ILM rule](#create-an-ilm-rule)
* [View ILM rules](#viewing-ilm-rules)
* [Delete an ILM rule](#delete-an-ilm-rule)
* [Reset ILM rules of a bucket](#reset-ilm-rules-of-a-bucket)

## Create an ILM rule

**Command:** `weka s3 bucket lifecycle-rule add`

Use the following command line to create an ILM rule:

`weka s3 bucket lifecycle-rule add <bucket> <expiry-days>  [--prefix prefix] [--tags tags]`

**Parameters**

| **Name**      | **Type** | **Value**                                            | **Limitations**                             | **Mandatory** | **Default** |
| ------------- | -------- | ---------------------------------------------------- | ------------------------------------------- | ------------- | ----------- |
| `bucket`      | String   | The name of the S3 bucket                            |                                             | Yes           |             |
| `expiry-days` | Number   | The number of days to wait before expiring an object | Minimum of 1 day                            | Yes           |             |
| `prefix`      | String   | The prefix of objects to apply the rule to           |                                             | No            |             |
| `tags`        | String   | Key value pair of object tags to apply the rule to   | Pairs of key values: `'<k1>=<v1>&<k2=<v2>'` | No            |             |

{% hint style="info" %}
**Note:** The `expiry-days` is the minimum time to wait before expiring an object. In extreme load and scale cases, it might take longer than `expiry-days` to delete an object.
{% endhint %}

## View ILM rules <a href="#viewing-ilm-rules" id="viewing-ilm-rules"></a>

**Command:** `weka s3 bucket lifecycle-rule list`‌

Use the following command line to view a bucket's existing ILM rules:‌

`weka s3 bucket lifecycle-rule list <bucket>`‌

**Parameters**

| **Name** | **Type** | **Value**                 | **Limitations** | **Mandatory** | **Default** |
| -------- | -------- | ------------------------- | --------------- | ------------- | ----------- |
| `bucket` | String   | The name of the S3 bucket | ​Content        | Yes           | ​Content    |

## Delete an ILM rule

**Command:** `weka s3 bucket lifecycle-rule remove`

Use the following command line to delete an ILM rule:

`weka s3 bucket lifecycle-rule remove <bucket> <rule>`

**Parameters**

| **Name** | **Type** | **Value**                    | **Limitations** | **Mandatory** | **Default** |
| -------- | -------- | ---------------------------- | --------------- | ------------- | ----------- |
| `bucket` | String   | The name of the S3 bucket    |                 | Yes           |             |
| `rule`   | String   | The ID of the rule to delete |                 | Yes           |             |

## Reset ILM rules of a bucket

**Command:** `weka s3 bucket lifecycle-rule reset`

Use the following command line to delete all the ILM rules of a specified bucket:

`weka s3 bucket lifecycle-rule reset <bucket>`

**Parameters**

| **Name** | **Type** | **Value**                 | **Limitations** | **Mandatory** | **Default** |
| -------- | -------- | ------------------------- | --------------- | ------------- | ----------- |
| `bucket` | String   | The name of the S3 bucket |                 | Yes           |             |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.weka.io/4.0/additional-protocols/s3/s3-information-lifecycle-management/s3-information-lifecycle-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
