Overview
Object Lifecycle Management (OLM) is a powerful feature of Google Cloud Storage (GCS) that allows you to automate the management of your data. Instead of manually moving or deleting files, you define a set of Rules consisting of Conditions and Actions. When an object meets the criteria of a condition, GCS automatically executes the specified action.
The “Grocery Store” Analogy
Imagine a grocery store manager. They have a policy for milk:
- Condition: If the milk is 1 day past the expiration date.
- Action: Throw it away (Delete).
- Condition: If the holiday is over.
- Action: Move it to the clearance aisle (Change Storage Class to a cheaper tier).
Core Concepts & Best Practices
OLM helps achieve the following GCP pillars:
- Cost Optimization: Automatically transition data to colder storage classes (Nearline, Coldline, Archive) as it ages.
- Operational Excellence: Reduces manual overhead and the risk of human error in data retention.
- Reliability: Ensures that only necessary data is kept, simplifying disaster recovery and data audits.
OLM Actions
- Delete: Permanently removes the object. For versioned buckets, this can delete the live version or older versions.
- SetStorageClass: Changes the storage class of the object (e.g., Standard to Coldline), helping save money on infrequently accessed data.
Comparison: GCS Storage Classes
| Class | Min Duration | Availability | Best Use Case |
|---|---|---|---|
| Standard | None | >99.9% | Frequent access, website assets, gaming. |
| Nearline | 30 Days | 99.9% | Data accessed < once per month (backups). |
| Coldline | 90 Days | 99.0% | Data accessed < once per quarter (disaster recovery). |
| Archive | 365 Days | 99.0% | Long-term legal/regulatory data retention. |
Scenario-Based Decision Matrix
If the requirement is… → Then use this OLM Condition:
- “Delete log files after 30 days” → Age: 30
- “Move old versions of files to Archive” → NumberOfNewerVersions: 1
- “Delete objects created before Jan 2023” → CreatedBefore: 2023-01-01
- “Only move files currently in Standard class” → MatchesStorageClass: [STANDARD]
Exam Tips: ACE Golden Nuggets
- Precedence: If multiple rules match, the
Deleteaction always takes precedence overSetStorageClass. - Propagation Delay: Lifecycle changes are not instantaneous. It can take up to 24 hours for changes to take effect after a rule is applied.
- Versioning: Use
IsLive: falseto target non-current versions of an object without affecting the current version. - Cost Trap: Remember that moving an object to a colder class via OLM still incurs the minimum storage duration charges of the original class if moved too early (though rare in OLM contexts, it’s vital for manual moves).
Visualizing Lifecycle Flow
Example: A typical cost-saving automated workflow.
Cloud Storage (GCS) is the primary service. OLM is configured at the Bucket level but applies to individual Objects.
Applying a “Delete” rule to a bucket without realizing it has “Object Versioning” enabled—older versions might persist and incur costs!
Log Rotation: Set a rule to delete all objects in /logs prefix after 14 days to keep storage lean.