Lifecycle Configuration for a Bucket with Versioning
A versioning-enabled bucket can have many versions of the same object, one current version and zero or more noncurrent (previous) versions. You can add lifecycle rules to buckets that have object versioning enabled or suspended. Using a lifecycle configuration, you can define actions specific to current and noncurrent object versions. For information about lifecycle management and bucket versioning, see the following topics in the Amazon Simple Storage Service Developer Guide:
The combined lifecycle and versioning functionality acts like a recycling bin, granting you the following benefits:
Recovering previous versions for a specified time to protect against unintended overwrites or deletions of your content.
Setting specific windows of time for retaining the noncurrent versions in Amazon S3, archiving in Amazon Glacier, or scheduling automatic deletion to help you control storage costs.
The following example walkthrough adds the following lifecycle configuration to a versioning-enabled bucket.
Archive the current object versions in the
documentsfolder 365 days after creation.
Transition noncurrent objects to the STANDARD_IA (infrequent access) storage class 30 days after they become noncurrent and transition them to the
GLACIERstorage class (archive them) 60 days after they become noncurrent. Permanently delete the noncurrent objects 425 days after they become noncurrent and remove expired object delete markers.
End and clean up multipart uploads that have not completed after 7 days.
Example: Add a Lifecycle Configuration Rule to a Versioned Bucket
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
In the Buckets list, choose the bucket whose lifecycle configuration you want to configure, choose Properties, and then choose Lifecycle.
Choose Add rule.
Select A Prefix and enter documents/ as the prefix to specify the subset of objects to which the rule applies, and then click Configure Rule. (In our example, entering "documents/" will apply the rule to all objects in the bucket's "documents" folder.)
For more information about key name prefixes and how they map to folders, go to Object Keys in the Amazon Simple Storage Service Developer Guide.
If you selected Whole Bucket the rule would apply to all objects in the bucket.
Configure the rule describing actions for both current and noncurrent (previous) object versions.
In the Action on Current Version section select the Archive to the Glacier Storage Class and specify 365 days.
Verify that the illustration in the EXAMPLE section match how you want your rule to work.
Actions selected in the Action on Previous Versions section occur according to the specified number of days after the object becomes noncurrent.
Select Transition to the Standard-Infrequent access Storage Class and enter 30 days, and then select Archive to the Glacier Storage Class and enter 60 days.
Select Permanently Delete and enter 425 days and then select Remove expired object delete marker. Amazon S3 will remove an expired object delete marker no sooner than 48 hours after the object expired.
Selecting Permanently Delete will not remove incomplete multipart uploads. You must select End and Clean up Incomplete Multipart Uploads as described in the next step to have incomplete multipart uploads removed.
Verify that the illustration in the EXAMPLE section matches how you want your rule to work.
It is a recommended best practice to select End and Clean up Incomplete Multipart Uploads. For our example, enter 7 for the number of days after the multipart upload initiation date that you want to end and clean up any multipart uploads that have not completed. Then choose Review.
For more information about multipart uploads, see Multipart Upload Overview in the Amazon Simple Storage Service Developer Guide.
Review and name your rule.
(Optional) You can give your rule a name to identify the rule, if you want. The name must be unique within the bucket. By default, Amazon S3 will generate a unique identifier for the rule.
Choose Edit next to Rule Target or Rule Configuration if you want to make changes.
Choose Create and Activate Rule when all of the settings are as you want them.
If the rule does not contain any errors, it is displayed in the Lifecycle pane.
For information on modifying, disabling, or deleting an existing lifecycle configuration rule, see Maintaining Lifecycle Configuration Rules.