Articles on: Object storage

Implementation of S3 LifeCycles

To implement lifecycles on your buckets, we recommend using a command prompt with S3 CLI.

Lifecycles are applied to buckets via a CLI command and a local file in “.JSON” format.

This file must be locally present on your machine.

The CLI command will “read” the Lifecycle file (JSON) on your machine and apply this information to your bucket.

The JSON file must not be dropped into the bucket, as this is pointless.

In the example below :
the file is called lifecycle-policy.json.
the bucket concerned is BUCKET_NAME.
the Leviia endpoint is s3.eu-west.leviia.com.

Apply a Lifecycle Configuration



aws s3api put-bucket-lifecycle-configuration --bucket BUCKET_NAME --lifecycle-configuration file://lifecycle-policy.json --endpoint-url https://s3.eu-west.leviia.com/


Retrieve/display Current Lifecycle Configuration



aws s3api get-bucket-lifecycle-configuration --bucket BUCKET_NAME --endpoint-url https://s3.eu-west.leviia.com/


Delete a Lifecycle Configuration



aws s3api delete-bucket-lifecycle --bucket BUCKET_NAME --endpoint-url https://s3.eu-west.leviia.com/


Warning: this deletes all bucket lifecycle rules.

Important notes :

Lifecycle rules are executed asynchronously, so there may be a delay between configuration and actual application.

To test your rules, we recommend that you first apply the configuration to a test bucket before using it in production.

Objects protected by S3 Object Lock (immutability) will not be deleted by lifecycle rules before the end of their retention period.


Other tutorials on S3 Lifecycles :


Understanding S3 Lifecycles
Setting S3 Lifecycles

Updated on: 28/05/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!