# aws s3api put-bucket-lifecycle-configuration

AWS CLI commands · Updated 16 November 2026

**Short answer:** aws s3api put-bucket-lifecycle-configuration --bucket my-bucket --lifecycle-configuration file://lifecycle.json sets the rules S3 uses to transition objects to cheaper storage classes and delete them after a number of days. It replaces the bucket's whole lifecycle configuration, so include every rule you want to keep.

## What the command does

A lifecycle configuration is a list of up to 1,000 rules. Each rule selects objects (by prefix, tags or size, or the whole bucket) and lists actions: transitions to other storage classes, expiration of current versions, expiration of noncurrent versions, removal of expired delete markers, and aborting incomplete multipart uploads.

S3 evaluates rules in the background, roughly once a day. Objects become eligible at midnight UTC after the day count passes, and the actual transition or deletion can lag behind that, though billing for expired objects stops once they are eligible.

## Syntax

```
# look at what is there first
aws s3api get-bucket-lifecycle-configuration --bucket my-bucket

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

If there is no configuration yet, the get call fails with `NoSuchLifecycleConfiguration`; that is expected.

## Worked examples

A practical `lifecycle.json` for a log bucket with versioning on:

```
{
  "Rules": [
    {
      "ID": "logs-tiering-and-expiry",
      "Filter": { "Prefix": "logs/" },
      "Status": "Enabled",
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER_IR" }
      ],
      "Expiration": { "Days": 365 },
      "NoncurrentVersionExpiration": { "NoncurrentDays": 30 }
    },
    {
      "ID": "whole-bucket-hygiene",
      "Filter": {},
      "Status": "Enabled",
      "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 },
      "Expiration": { "ExpiredObjectDeleteMarker": true }
    }
  ]
}
```

Rule one tiers logs down and deletes them after a year, removing overwritten versions after 30 days. Rule two applies to the whole bucket (empty filter): it cleans up abandoned multipart uploads, which are billed but invisible to `ls`, and removes delete markers that no longer hide anything.

**Expire only objects with a tag**:

```
{ "Rules": [{
  "ID": "tmp-tagged",
  "Filter": { "Tag": { "Key": "retention", "Value": "7d" } },
  "Status": "Enabled",
  "Expiration": { "Days": 7 }
}] }
```

**Temporarily pause a rule**: set its `Status` to `Disabled` and put the full configuration back.

## Rule elements

| Element | Notes |
|---|---|
| `Filter` | `Prefix`, `Tag`, `ObjectSizeGreaterThan`/`LessThan`, or `And` to combine. `{}` means all objects. |
| `Transitions` | Moving to `STANDARD_IA` or `ONEZONE_IA` requires objects to be at least 30 days old. |
| `Expiration` | On a versioned bucket, this adds a delete marker; data remains as a noncurrent version. |
| `NoncurrentVersionExpiration` | Permanently deletes old versions after `NoncurrentDays`; optionally keep the newest N with `NewerNoncurrentVersions`. |
| `AbortIncompleteMultipartUpload` | Cannot be combined with a tag-based filter. |

## Gotchas

- **It replaces everything.** Putting a one-rule file wipes out all other rules. Always start from the output of `get-bucket-lifecycle-configuration`.
- **Small objects may not transition.** By default S3 skips transitions for very small objects (under 128 KB at the time of writing), and per-object transition charges can outweigh savings for many small files.
- **Archive classes have minimum durations.** Deleting or transitioning objects early from IA or Glacier classes incurs a minimum-storage charge.
- **Expiration is destructive.** On an unversioned bucket it deletes data permanently. Test with a narrow prefix first.
- **Check the response for warnings** and confirm with the get call; a successful put says nothing about whether the rules match any objects.

## Questions

### Does put-bucket-lifecycle-configuration overwrite existing rules?

Yes. It replaces the whole configuration, so fetch the current rules first and include them in your file.

### How long until a lifecycle rule takes effect?

Rules are evaluated asynchronously, about once a day. Expect transitions and deletions to start within a day or two of objects becoming eligible.

### How do I delete all lifecycle rules?

Run aws s3api delete-bucket-lifecycle --bucket my-bucket.

## When this happens away from your desk

Storage costs creep up quietly, and lifecycle rules are usually the fix. CloudConsole, a phone app for AWS, is built to show costs and resources on a phone so growth like this is easier to notice.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [AWS CLI Command Reference: s3api put-bucket-lifecycle-configuration](https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-lifecycle-configuration.html)
- [PutBucketLifecycleConfiguration API reference](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html)

## Related

- [aws s3api list-object-versions](https://cloudconsole.dev/cli/s3api-list-object-versions)
- [How to delete an S3 bucket with versioning enabled](https://cloudconsole.dev/how-to/delete-s3-bucket-with-versioning)
- [How to find S3 bucket size](https://cloudconsole.dev/how-to/find-largest-s3-buckets)
- [Why is my AWS bill so high?](https://cloudconsole.dev/how-to/why-is-my-aws-bill-so-high)
- [aws s3api list-objects-v2](https://cloudconsole.dev/cli/s3api-list-objects-v2)
- [aws s3api delete-objects](https://cloudconsole.dev/cli/s3api-delete-objects)

---

Source: https://cloudconsole.dev/cli/s3api-put-bucket-lifecycle-configuration

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
