GCP
Intermediate 15 min read GCP

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.

Cloud Storagebucketsstorage classeslifecycleobject storageGCS
Before we start

What you will learn

  • Choose storage classes by access pattern
  • Configure lifecycle rules and object versioning
  • Secure buckets with IAM and signed URLs
In 60 seconds

Cloud Storage offers buckets with classes — Standard, Nearline, Coldline, Archive — pricing by access frequency. Lifecycle rules move/delete objects automatically; versioning + retention protect history.

Introduction

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.

Motivation

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.
Think about it

Mental model

Imagine

A library with shelves, a cold-storage wing and a vault

Think of

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.

Mechanics

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.

Upload (Standard)
Transition 180d
Transition 1y
Archive 2y
Delete / retain
Real world

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.
Guidelines

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.
Watch out

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).
Root cause analysis

Common issues

Error
gsutil cp gets permission denied
Root cause

Insufficient storage.objectAdmin on the bucket

Fix

Grant storage.objectAdmin (or user-scoped) and retry; verify with gsutil iam get.

Error
Object bahaves as deleted after 'update'
Root cause

Versioning off + retention off → overwrite replaces

Fix

Enable versioning and retention on critical buckets.

Error
Restore from archived class hangs
Root cause

Archive retrieval requires rehydrating the object first

Fix

Issue a rewrite/transition back to a warmer class and poll the operation before reading.

When things break

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.
Interviews

Interview checkpoint

Test yourself

Quick quiz

0/1
1

Which GCS feature automates moving old objects to cheaper classes?

Go deeper

Official documentation