Menu
Amazon Simple Storage Service
Console User Guide

How Do I Create a Lifecycle Policy for an S3 Bucket?

You can use lifecycle policies to define actions you want Amazon S3 to take during an object's lifetime (for example, transition objects to another storage class, archive them, or delete them after a specified period of time).

You can define a lifecycle policy for all objects or a subset of objects in the bucket by using a shared prefix (that is, objects that have names that begin with a common string).

A versioning-enabled bucket can have many versions of the same object, one current version and zero or more noncurrent (previous) versions. Using a lifecycle policy, you can define actions specific to current and noncurrent object versions. For more information, see Object Lifecycle Management and Object Versioning and Using Versioning in the Amazon Simple Storage Service Developer Guide.

To create a lifecycle policy

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.

  2. In the Bucket name list, choose the name of the bucket that you want to create a lifecycle policy for.

  3. Choose the Management tab, and then choose Add lifecycle rule.

    1. If the bucket does not have a lifecycle policy, you can choose Get started.

  4. In the Lifecycle rule dialog box, type a name for your rule to help identify the rule later. The name must be unique within the bucket. Configure the rule as follows:

    • To apply this lifecycle rule to all objects with a specified name prefix (i.e., objects whose name begins with a common string), type in a prefix. You can also limit the lifecycle rule scope to one or more object tags. You can combine a prefix and tags. For more information about object name prefixes, see Object Keys in the Amazon Simple Storage Service Developer Guide. For more information about object tags, see Object Tagging in the Amazon Simple Storage Service Developer Guide

    • To apply this lifecycle rule to all objects in the bucket, choose Next.

  5. You configure lifecycle rules by defining rules to transition objects to the Standard-IA and Amazon Glacier storage classes. For more information, see Storage Classes in the Amazon Simple Storage Service Developer Guide.

    You can define transitions for current or previous object versions, or for both current and previous versions.

    1. Select Current version to define transitions that are applied when an object is created that is within the scope of the rule.

      Select Previous version to define transitions that are applied when an object is created that is within the scope of the rule.

    2. Choose Add transitions and specify one of the following transitions:

      • Choose Transition to Standard-IA after, and then type the number of days after the creation of an object that you want the transition to be applied (for example, 30 days).

      • Choose Transition to Amazon Glacier after, and then type the number of days after the creation of an object that you want the transition to be applied (for example, 100 days).

  6. When you are done configuring transitions, choose Next.

  7. Select Expiration and then enter the number of days after object creation to delete the object (for example, 455 days).

  8. Select Permanently delete previous versions and then enter the number of days after an object becomes a previous version to permanently delete the object (for example, 455 days).

  9. It is a recommended best practice to always select Clean up incomplete multipart uploads. For example, type 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. For more information about multipart uploads, see Multipart Upload Overview in the Amazon Simple Storage Service Developer Guide.

  10. Choose Next.

  11. For Review, verify the settings for your rule. If you need to make changes, choose Previous. Otherwise, choose Save.

  12. If the rule does not contain any errors, it is listed on the Lifecycle page and is enabled.