Home

Versioned S3 bucket with lifecycle policy

Cost Optimization

With s3, you are charged more for objects that are on faster classes. By moving rarely used objects to slower classes, we can reduce costs.

However, there are extra costs incurred for moving objects between classes, as well as retriving them later on. Each time you access the objects, you get charged on the slower classes. Thus, we must only move really rarely objects on slower classes.

S3 class Storage Cost(/gb mo) Retrival cost(/1000 requests) Retrival cost(/gb)
S3 Standard $0.023 0 0
S3 Standard-Infrequent Access $0.0125 0 $0.01
S3 Glacier Flexible Retrieval $0.0036 $0.05 $0.01

Lifecycle Policy

The following policy was created by using the console. Then the aws cli command aws s3api get-bucket-lifecycle --bucket was used to get the policy in json.

It moves all objects to standard ia class after 30 days. The current objects are expired after a year. After 90 days the non-current objects are moved to glacier flexible. After 2 years of being non-current, they are deleted.

{
    "Rules": [
        {
            "Expiration": {
                "Days": 365
            },
            "ID": "all",
            "Status": "Enabled",
            "Transition": {
                "Days": 30,
                "StorageClass": "STANDARD_IA"
            },
            "NoncurrentVersionTransition": {
                "NoncurrentDays": 30,
                "StorageClass": "STANDARD_IA"
            },
            "NoncurrentVersionExpiration": {
                "NoncurrentDays": 720
            }
        },
        {
            "Expiration": {
                "ExpiredObjectDeleteMarker": false
            },
            "ID": "incomplete multipart",
            "Status": "Enabled",
            "AbortIncompleteMultipartUpload": {
                "DaysAfterInitiation": 1
            }
        },
        {
            "Expiration": {
                "Days": 60
            },
            "ID": "logs",
            "Status": "Enabled",
            "NoncurrentVersionExpiration": {
                "NoncurrentDays": 365
            }
        }
    ]
}