How to create S3 bucket lifecycle policy
First, let’s take an example of an organization that stores the application logs in the S3 Standard storage class by default and they have a set of rules to access logs like:
- Application logs access frequently till 30 days.
- After 30 days logs are infrequently accessed, and after 60 days logs are not required.
- To meet the organization’s compliance rules, they have to maintain the logs for 465 days.
In order to optimize the storage cost and implement above use case, follow the Steps to configure S3 bucket object life cycle policy.
1. Sign in to the AWS Console and open the Amazon S3
2. Select the bucket in which you want to create a lifecycle policy.
Go to the Management tab, and then select Add lifecycle rule.
3. In the life cycle rule wizard, type a name (i.e. cloudiofy-logs-lifecycle-rule) for your rule and click on the Next
4. Configure lifecycle rules to move the objects:
- From Standard Storage class to Standard-Infrequent Access after 30 days of creation
- From Standard-Infrequent Access to S3 Glacier after 60 days of creation
5. Configure lifecycle rules to delete all logs 465 days after creation.
Clean up incomplete multipart uploads: It is a recommended best practice setting and then click on the Next.
6. Under review verify your configuration settings and click on the Save. After saving a screen visible with success message.
Lifecycle policy configuration completed for the defined bucket (i.e. cloudiofy-application-logs)