DevOps Peach

GCP Basics · Storage & Databases – Cloud Storage, Cloud SQL and Choosing a Database · Lesson 1 of 5

Cloud Storage: Buckets, Classes and Lifecycle

Buckets hold objects in a region, dual-region or multi-region; storage classes trade storage price for access cost, and lifecycle rules move or delete objects automatically.

Practice interactively →

Cloud Storage stores objects (files up to 5 TiB) in buckets. Every class has the same millisecond latency; they differ in price per GB, minimum storage duration and retrieval fees.

flowchart TB
  APP["App uploads invoices"] --> B["Bucket gs://dl-invoices<br/>asia-southeast1"]
  B --> STD["Standard<br/>0–30 days"]
  STD -- "age 30" --> NL["Nearline"]
  NL -- "age 90" --> CL["Coldline"]
  CL -- "age 365" --> AR["Archive"]
  AR -- "age 2555" --> DEL["Delete after 7 years"]
  %% step APP: The app writes new invoices into the bucket in Singapore.
  %% step B: The bucket has a location type (region here) and a default storage class.
  %% step STD: New objects are read often, so they start in Standard.
  %% step NL: A lifecycle rule moves objects older than 30 days to Nearline.
  %% step CL: After 90 days they move to Coldline, which is cheaper to store but costs more to read.
  %% step AR: After a year they go to Archive for long-term retention.
  %% step DEL: A final rule deletes them when the legal retention period ends.

Location types

Type Example Use
Region asia-southeast1 Data next to compute; lowest cost
Dual-region ASIA1 (Tokyo + Osaka) or a custom pair High availability across two regions, turbo replication option
Multi-region ASIA, EU, US Content served to users across a continent

Bucket names are globally unique and the location cannot be changed after creation.

Storage classes

Class Minimum duration Typical use
Standard none Hot data, websites, analytics
Nearline 30 days Accessed about once a month
Coldline 90 days Accessed about once a quarter
Archive 365 days Backups and compliance archives

Deleting or moving an object before its minimum duration is charged as if it stayed. Autoclass moves objects between classes automatically based on access, if you do not know the pattern.

Lifecycle rules

Actions: SetStorageClass, Delete, AbortIncompleteMultipartUpload. Conditions: age, createdBefore, isLive, numNewerVersions, matchesStorageClass, daysSinceNoncurrentTime…

{"rule": [
  {"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"}, "condition": {"age": 30}},
  {"action": {"type": "Delete"}, "condition": {"age": 2555}}
]}

Protecting objects

gcloud storage buckets create gs://dl-invoices --location=asia-southeast1   --default-storage-class=STANDARD --uniform-bucket-level-access
gcloud storage cp ./invoices/*.pdf gs://dl-invoices/2026/11/
gcloud storage buckets update gs://dl-invoices --lifecycle-file=lifecycle.json
Command Meaning
gcloud storage ls gs://dl-invoices/2026/ List objects
gcloud storage rsync ./site gs://dl-site --recursive Sync a folder
gcloud storage buckets update gs://dl-invoices --versioning Turn on versioning

Traps: the bucket location is permanent; Archive is cheap to store but reading it has retrieval fees; lifecycle changes can take up to 24 hours to apply.

Practice interactively →