Lifecycle rules
Lifecycle rules delete things for you on a schedule: temporary files after a few days, old versions after a month, unfinished multipart uploads after a week. Setting rules needs an Admin key.
Supported rules
Section titled “Supported rules”| Rule | What it does | Buckets |
|---|---|---|
Expiration with Days or Date |
Deletes current objects after a number of days or on a date. On a versioned bucket it adds a delete marker instead. | All |
AbortIncompleteMultipartUpload |
Cancels multipart uploads that weren’t finished after DaysAfterInitiation days, freeing their parts. |
All |
NoncurrentVersionExpiration |
Permanently deletes noncurrent versions NoncurrentDays after they were replaced, optionally keeping the newest NewerNoncurrentVersions. |
Versioned |
Expiration with ExpiredObjectDeleteMarker |
Removes delete markers that no longer have any versions behind them. | Versioned |
Filters: by key prefix and by object size (ObjectSizeGreaterThan, ObjectSizeLessThan) on every bucket; by tags as well on buckets with versioning.
Days are counted like S3: rounded up to the next midnight UTC. Rules run in the background, so an object can stay a little while after its expiry time. Versions under object lock are never deleted by a rule.
Transitions (moving objects to another storage class) aren’t supported: Hive Buckets has one storage class, so a rule with a Transition is refused.
Example
Section titled “Example”{ "Rules": [ { "ID": "expire-tmp", "Status": "Enabled", "Filter": { "Prefix": "tmp/" }, "Expiration": { "Days": 7 } }, { "ID": "abort-unfinished-uploads", "Status": "Enabled", "Filter": { "Prefix": "" }, "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 3 } }, { "ID": "old-versions", "Status": "Enabled", "Filter": { "Prefix": "" }, "NoncurrentVersionExpiration": { "NoncurrentDays": 30, "NewerNoncurrentVersions": 3 } } ]}The old-versions rule only applies to a bucket with versioning; leave it out otherwise.
EP=https://s3.dockhive.ioaws s3api put-bucket-lifecycle-configuration --bucket my-app-uploads \ --lifecycle-configuration file://lifecycle.json --endpoint-url $EPaws s3api get-bucket-lifecycle-configuration --bucket my-app-uploads --endpoint-url $EPaws s3api delete-bucket-lifecycle --bucket my-app-uploads --endpoint-url $EP