Lifecycle Configuration
The Lifecycle Configuration is used to configure the lifecycle of your objects, so they are stored cost effectively.
The only operation currently supported in the lifecycle configuration management is the NoncurrentVersionExpiration
.
Setting the Lifecycle Configuration is possible through its APIs:
PutBucketLifecycleConfiguration
- for setting the configuration; it overrides the existing one, if anyGetBucketLifecycleConfiguration
- for retrieving the currently configured lifecycle configurationDeleteBucketLifecycle
- for deleting the currently configured lifecycle configuration
The NoncurrentVersionExpiration
rule
The NoncurrentVersionExpiration rule serves the purpose of deleting object versions that are exceeding the amount of versions to keep, defined by the NewerNoncurrentVersions
parameter, and have been noncurrent for more than NoncurrentDays
.
Example:
Suppose I have an object with only 2 noncurrent versions and the configured rule has a NewerNoncurrentVersions
of 2: those two versions won't be deleted.
If instead the noncurrent versions are 3, the older one will be deleted because exceeds the amount of NewerNoncurrentVersions
, but only if it has been noncurrent for more than NoncurrentDays
.
The NoncurrentDays
(i.e. the number of days a version has been noncurrent) for a version are calculated starting counting since when its next version gets created.
The amount of days a version has been noncurrent is always rounded down to the largest integer less than or equal to the actual passed days.
Practical example
- Create a file containing the following lifecycle configuration, named
lifecycle.json
:
{
"Rules": [
{
"Status": "Enabled",
"NoncurrentVersionExpiration": {
"NewerNoncurrentVersions": 3,
"NoncurrentDays": 2
}
}
]
}
- In the same folder, invoke the following command to set the lifecycle configuration for the bucket:
aws s3api --endpoint https://s3.cubbit.eu --bucket my-cubbit-bucket put-bucket-lifecycle-configuration --lifecycle-configuration file://lifecycle.json
If the command succeeds, the lifecycle configuration has been successfully applied. To verify it, you can invoke the following command:
aws s3api --endpoint https://s3.cubbit.eu --bucket my-cubbit-bucket get-bucket-lifecycle-configuration
Please verify that you have replaced "my-cubbit-bucket" with an existing bucket
The unsupported features
Currently only one rule per bucket is supported.
Here's a list of unsupported instructions:
AbortIncompleteMultipartUpload
Expiration
Filter
- even if specified, it will be ignoredID
NoncurrentVersionTransition
Prefix
Transition