Applying a Lifecycle Configuration to Your Objects

You can apply a lifecycle configuration to the objects of a bucket. A lifecycle configuration allows you, for example, to set an expiration date to the objects after which they will be automatically deleted.

If a lifecycle configuration has already been added to your bucket, using this command will replace it with a new one.

This feature is not available from Cockpit. This documentation only describes the procedure using AWS CLI.

To apply a lifecycle configuration to the objects of your bucket, use the put-bucket-lifecycle-configuration command following this syntax:

Request sample
$ aws s3api put-bucket-lifecycle-configuration \
    --profile YOUR_PROFILE \
    --bucket BUCKET \
    --lifecycle-configuration file://path/to/configuration/file \

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • bucket: The name of the bucket to which you want to add the lifecycle configuration.

  • lifecycle-configuration: The path to the JSON configuration file containing the lifecycle rules to apply to your objects. For more information on how to write this file, see Lifecycle Configuration Reference.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The lifecycle configuration is applied to the objects of your bucket.

Related Pages

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.