Overview and What You Will Learn
In this lab, you will upload objects to buckets using different storage classes, manually change a blob's class, and calculate the real cost impact of the minimum storage duration penalty when data doesn't stay as long as the chosen class expects.
Why This Matters in Production
A team migrates old audit logs into Coldline storage for its lower per-GB price, then needs to delete a subset of those logs after 45 days for an unrelated data cleanup requirement - well before Coldline's 90-day minimum has elapsed. The deletion still bills as if those objects had been stored the full 90 days, meaning the "cheaper" class ended up costing more than Standard would have for that specific short-lived data.
Core Principles
Cloud Storage classes trade cost against access frequency and a genuinely important detail: a minimum storage duration attached to every class colder than Standard.
+------------------------------------------+| Standard || Frequently accessed data || No minimum storage duration |+------------------------------------------+| Nearline || Accessed roughly once a month or less || 30-day minimum storage duration |+------------------------------------------+| Coldline || Accessed roughly once a quarter or less || 90-day minimum storage duration |+------------------------------------------+| Archive || Accessed less than once a year || 365-day minimum storage duration |+------------------------------------------+Detailed Step-by-Step Practical Lab
- Create a project and a bucket using the Standard storage class:
gcloud projects create gcp-storage-lab-2026 --name="Storage Classes Lab"gcloud config set project gcp-storage-lab-2026 gcloud storage buckets create gs://storage-lab-standard-2026 \ --location=asia-south1 \ --default-storage-class=STANDARD- Upload a test file, then check what storage class it landed in:
echo "test log content" > audit-log.txtgcloud storage cp audit-log.txt gs://storage-lab-standard-2026/ gcloud storage objects describe gs://storage-lab-standard-2026/audit-log.txt \ --format="value(storageClass)"- Manually change that object's storage class to Coldline:
gcloud storage objects update gs://storage-lab-standard-2026/audit-log.txt \ --storage-class=COLDLINE- Confirm the change took effect:
gcloud storage objects describe gs://storage-lab-standard-2026/audit-log.txt \ --format="value(storageClass)"- Create a Lifecycle rule that automatically transitions objects to Coldline after 90 days, and to Archive after 365 days:
cat > lifecycle-config.yaml << 'LIFECYCLEEOF'rule: - action: type: SetStorageClass storageClass: COLDLINE condition: age: 90 - action: type: SetStorageClass storageClass: ARCHIVE condition: age: 365LIFECYCLEEOF gcloud storage buckets update gs://storage-lab-standard-2026 \ --lifecycle-file=lifecycle-config.yaml- Confirm the Lifecycle policy was applied:
gcloud storage buckets describe gs://storage-lab-standard-2026 \ --format="value(lifecycle)"- Clean up:
gcloud storage rm --recursive gs://storage-lab-standard-2026gcloud projects delete gcp-storage-lab-2026 --quietProduction Best Practices & Common Pitfalls
Common MistakeChoosing a colder storage class purely for its lower per-GB storage price, without checking the minimum storage duration against how long the data will actually be kept before being deleted or overwritten. If data is genuinely likely to be deleted or replaced before the minimum duration elapses, the "cheaper" class can end up costing more overall.
TipUse a Lifecycle rule to automate the transition to colder classes based on object age, rather than manually reclassifying objects. This ensures data ages into cheaper storage automatically and consistently, without relying on anyone remembering to do it.
- Retrieval costs, not just storage costs, differ significantly between classes. Archive has both the lowest storage cost and the highest retrieval cost - appropriate for data that is genuinely almost never read, not merely data that is "old."
- Autoclass is a bucket-level feature that automatically manages storage class transitions per-object based on actual access patterns, removing the need to write and maintain Lifecycle rules manually - worth considering for buckets with genuinely unpredictable access patterns.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
gcloud storage buckets create --default-storage-class= |
Create a bucket with a specific default class |
gcloud storage objects update --storage-class= |
Manually change an object's storage class |
gcloud storage buckets update --lifecycle-file= |
Apply a Lifecycle Management policy |
gcloud storage objects describe --format="value(storageClass)" |
Check an object's current storage class |