Bucket Lifecycle
The lifecycle configuration allow you to set an expiration policy on your objects and auto-delete them.
For example, you may need for some objects to be deleted automatically.
In this example, we will automatically create a policy to delete objects with a key starting with reports/
after 90 days. We could use a GUI Client or AWS SDK, but we will use AWS CLI to do so.
Limitations
Lifecycle is a bucket level concept.
Maximum of 1000 lifecycle rules per bucket is applicable.
There may be a delay between the expiration date and the date at which Object Storage Service removes an object.
Always round up the resulting time to the next day midnight UTC.
Deleted Object cannot be restored.
Manage lifecycle policy
Bucket lifecycle configuration can be managed using aws s3api (other tools or SDK works too):
put-bucket-lifecycle
get-bucket-lifecycle
delete-bucket-lifecycle
We use aws s3 and **aws s3api
**command line tools from AWSCLIv2 on Linux.
${S3_ENDPOINT}
& ${S3_PROFILE}
are environment variables.
Create a lifecycle policy
Create JSON file and put your policy in it:
Apply it to the bucket: bucket-test
Get a lifecycle configuration
Delete a lifecycle configuration
Supported lifecycle configuration elements
Last updated