🔥 Stop Wasting Time on Manual Storage Management
Imagine you’re storing thousands of files in Google Cloud Storage — logs, backups, media files.
Manually moving old files to cheaper storage, archiving, or deleting them would take hours or even days.
Enter Object Lifecycle Management (OLM) in GCP — a way to automatically manage the storage objects over time, saving cost and effort.
🧠 What Is Object Lifecycle Management?
Object Lifecycle Management in GCP lets you define rules that automatically handle objects in Cloud Storage buckets based on:
- Object age
- Storage class
- Versioning
- Custom conditions
Instead of manually moving or deleting files, you define rules once, and Google Cloud executes them for you.
🔄 What Lifecycle Rules Can Do
| Rule Type | Example Action |
|---|---|
| Age-based | Delete objects after 90 days |
| Storage class | Move to Nearline after 30 days |
| Versioned files | Keep only last 3 versions |
| Date-based | Delete objects before a specific date |
🧪 Real-World Use Case
Logs Retention
You store application logs in a GCS bucket:
| Age | Action |
|---|---|
| 0–30 days | Standard Storage |
| 31–90 days | Nearline Storage |
| 91+ days | Archive Storage |
| 365 days | Delete |
✅ Automatic, predictable, and cost-efficient.
⚙️ Example: JSON Lifecycle Rule
Here’s how you would define lifecycle rules in JSON:
{ "lifecycle": { "rule": [ { "action": { "type": "SetStorageClass", "storageClass": "NEARLINE" }, "condition": { "age": 30 } }, { "action": { "type": "SetStorageClass", "storageClass": "ARCHIVE" }, "condition": { "age": 90 } }, { "action": { "type": "Delete" }, "condition": { "age": 365 } } ] }}
⚙️ How to Apply the Lifecycle Rule
Using gsutil:
gsutil lifecycle set lifecycle.json gs://your-bucket-name
🔹 Command Breakdown
| Part | Meaning |
|---|---|
gsutil | Google Cloud Storage CLI tool |
lifecycle | Lifecycle management command group |
set | Keyword → apply this lifecycle configuration |
lifecycle.json | JSON file with your lifecycle rules |
gs://your-bucket-name | The target bucket where rules will be applied |
🔹 Or in the GCP Console
Bucket → Lifecycle → Add Rule → Paste equivalent rules
🎯 Key Benefits of Object Lifecycle Management
- Saves storage costs by moving/deleting old objects
- Reduces manual work
- Enforces data retention policies
- Improves storage efficiency
🔚 One-Liner Summary
“Object Lifecycle Management in GCP automates how your Cloud Storage data is retained, archived, and deleted over time to reduce cost and effort.”
✅ Mock Cloud Digital Leader Exam Questions
- Scenario: You have a bucket storing daily logs. You want to automatically delete logs older than 90 days.
Question: Which GCP feature would you use?
Answer: Object Lifecycle Management - Scenario: You want to move objects older than 30 days to Nearline storage automatically.
Question: How would you implement this?
Answer: Define a lifecycle rule withSetStorageClassaction andage: 30condition - Scenario: You want to retrieve current lifecycle rules applied to a bucket.
Question: Which command will you use?
Answer:gsutil lifecycle get gs://your-bucket-name
Leave a comment