You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Object lifecycle management allows you to define rules that automatically transition objects between storage classes or delete them based on conditions like age, storage class, or version status. This is essential for cost optimisation and data governance — ensuring that data moves to cheaper storage as it ages and is deleted when no longer needed.
Lifecycle rules are configured at the bucket level. Each rule consists of:
Cloud Storage evaluates lifecycle rules once per day (asynchronously). Changes are not instantaneous — there may be a delay of up to 24 hours.
Transitions an object to a different (colder) storage class:
{
"lifecycle": {
"rule": [
{
"action": { "type": "SetStorageClass", "storageClass": "NEARLINE" },
"condition": { "age": 30 }
},
{
"action": { "type": "SetStorageClass", "storageClass": "COLDLINE" },
"condition": { "age": 90 }
},
{
"action": { "type": "SetStorageClass", "storageClass": "ARCHIVE" },
"condition": { "age": 365 }
}
]
}
}
Note: You can only transition to a colder class (Standard to Nearline to Coldline to Archive). To move to a warmer class, you must manually rewrite the object or use Autoclass.
Permanently removes the object:
{
"action": { "type": "Delete" },
"condition": { "age": 730 }
}
Cleans up incomplete multipart uploads:
{
"action": { "type": "AbortIncompleteMultipartUpload" },
"condition": { "age": 7 }
}
| Condition | Description |
|---|---|
| age | Number of days since the object was created |
| createdBefore | Object was created before this date |
| isLive | true for live (current) versions; false for non-current versions |
| numNewerVersions | Number of newer versions that exist (for versioned buckets) |
| matchesStorageClass | Object is currently in the specified class(es) |
| matchesPrefix | Object name starts with the specified string |
| matchesSuffix | Object name ends with the specified string |
| daysSinceNoncurrentTime | Days since the object became non-current |
| daysSinceCustomTime | Days since a custom time was set on the object |
You can combine multiple conditions in a single rule — all conditions must be true for the action to trigger (AND logic).
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.