Cloud Storage and Buckets
Objects, classes and lifecycle in Google Cloud
Cloud Storage is GCP's object storage: buckets with storage classes (Standard, Nearline, Coldline, Archive), lifecycle rules, IAM/ACL access and strong consistency. It's the data lake's front door.
What you will learn
- Choose storage classes by access pattern
- Configure lifecycle rules and object versioning
- Secure buckets with IAM and signed URLs
Cloud Storage offers buckets with classes — Standard, Nearline, Coldline, Archive — pricing by access frequency. Lifecycle rules move/delete objects automatically; versioning + retention protect history.
What is this?
Google Cloud Storage (GCS) is a global object store: buckets hold blobs (objects) accessible via gsutil, REST, or clients in any language. Storage classes set cost vs availability/redundancy: Standard (hot), Nearline (~30 days), Coldline (~90 days), Archive (~365 days). Features: strong consistency, object versioning, lifecycle management, retention locks, IAM roles (objectViewer/Admin) plus legacy ACLs, signed URLs for temporary access, and encryption by default (CSEK/KMS options). Buckets can be regional, dual-region, or multi-region.
Why do you need it?
- It is the universal landing zone: backups, images, logs, ML data, static site hosting.
- Class + lifecycle is the cheapest way to keep cold data for years without an archive server.
- Versioning + retention make accidental deletion recoverable.
- Signed URLs give time-scoped access without public buckets.
Mental model
A library with shelves, a cold-storage wing and a vault
GCS classes
Standard is the busy reading room; Nearline/Coldline are deeper, cheaper wings for rarely-read tomes; Archive is the vault where you pay less to store and more/ slower to retrieve. The librarian (lifecycle) moves books between wings as they age.
How it works
- Buckets are named globally; objects have keys and metadata (no folders, but prefixes look like them).
- Classes bill for storage + access: Standard costs more to hold, cheap to read; Archive is reverse.
- Lifecycle: rules match age/size/prefix to transition to a colder class or delete objects.
- Versioning keeps old object versions; object retention locks prevent deletion for compliance.
- Access: IAM (via service accounts/users), signed URLs, ACLs for edge cases, and public-prevention policy.
Lifecycle-facilitated class transitions.
In production
- A data lake stores raw Parquet in Standard, and a lifecycle rule pushes >90-day partitions to Coldline.
- A media pipeline writes uploads with versioning + retention; a signed URL lets editors push without keys.
- A compliance team archrives audit logs in Archive with a 7-year retention lock.
Best practices
- Enable versioning on buckets that matter; add retention when legally required.
- Use IAM (objectViewer) and signed URLs over ACLs; set publicAccessPrevention= enforced.
- Class transitions via lifecycle; review inventory monthly for class drift.
- Pay for egress: keep consumers in-region or in the same project where possible.
Common mistakes
- Serving media from Standard when a CDN/CloudFront or lower class would do.
- Forgetting lifecycle deletes edges cases — age counts from object creation/now, watch AB-AB age against 'days since creation'.
- Public buckets enabled 'just this once' — permanent.
- Using GCS for random-access mutable file I/O (it's object storage with higher latency).
Common issues
gsutil cp gets permission deniedInsufficient storage.objectAdmin on the bucket
Grant storage.objectAdmin (or user-scoped) and retry; verify with gsutil iam get.
Object bahaves as deleted after 'update'Versioning off + retention off → overwrite replaces
Enable versioning and retention on critical buckets.
Restore from archived class hangsArchive retrieval requires rehydrating the object first
Issue a rewrite/transition back to a warmer class and poll the operation before reading.
Debugging tips
- Object 403? Check IAM binding on bucket AND the ACL; disabled public access is a common cause.
- Serving stale objects? Check versioning/lifecycle and the CDN's cache TTL.
- Cost climb? Inspect storage class distribution and lifecycle coverage via gsutil du --class.
- Signed URL expires unexpectedly? Clock skew or wrong query params.
Interview checkpoint
Quick quiz
Which GCS feature automates moving old objects to cheaper classes?