You can use lifecycle policies to define actions you want Amazon S3 to take during an object’s lifetime, e.g. transition objects to another storage class, archiving objects, or deleting objects after a specified period.
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.
We are going to setup a lifecycle policy that will move noncurrent (previous) versions of your objects to the S3 Infrequent Access (IA) tier after 30 days and then delete them 30 days later.
1.In your bucket’s overview page, select the Management tab.
2.Under “Lifecycle rules” select the Create lifecycle rule button. This should then open the “Create lifecycle rule” page.You now have a lifecycle policy that will move previous versions of your objects to S3-IA after 30 days and then delete them 30 days later.
3.Under “Transition noncurrent versions of objects between storage classes” select Standard-IA for “Choose storage class transitions”. Enter 30 for “Days after objects become noncurrent”.
4.Under “Permanently delete noncurrent versions of objects” enter 60. This will delete an object 60 days after it becomes previous versions. (30 days after it is moved to S3-IA.)
5.Select Create rule when you have finished reviewing the summary.
6.You now have a lifecycle policy that will move previous versions of your objects to S3-IA after 30 days and then delete them 30 days later.