Skip to content
Tutorials Center
My learning

Topics

Lesson 45 of 45 ยท Practice and Review

Google Cloud Cheat Sheet

A quick Google Cloud reference: everyday gcloud commands, a service chooser, and limits and defaults worth remembering, with a runnable service picker.

This page is the one to keep open in a tab. It collects the gcloud commands you type most, a table for choosing a service, and a list of defaults and limits that are easy to forget. Each item links to the lesson that explains it.

The commands are read-only here because they need an account. The service chooser at the end is a runnable stand-in: a small function that encodes the decision table, not a Google tool. Limits change over time, so treat numbers as a reminder and confirm them in the official documentation before you rely on them.

What is on this page

Commands Setup, compute, storage, data.
Chooser Which service for which job.
Defaults Numbers worth remembering.

Verify limits in the docs before relying on them.

1 / 2

Setup and configuration

Learn more in the gcloud CLI.

Terminal
gcloud auth login                       # sign in as a user
gcloud auth application-default login   # credentials for local code
gcloud auth list                        # who am I?
gcloud config set project my-project-id
gcloud config get project
gcloud config configurations list       # named profiles
gcloud services enable run.googleapis.com
gcloud projects list
gcloud components update

Output control works on almost every command:

Terminal
gcloud compute instances list --format="table(name,zone.basename(),status)"
gcloud compute instances list --filter="status=RUNNING" --format=json
gcloud run services list --format="value(metadata.name)"

IAM and secrets

See IAM, service accounts and Secret Manager.

Terminal
gcloud projects get-iam-policy my-project-id
gcloud projects add-iam-policy-binding my-project-id \
  --member="user:[email protected]" --role="roles/viewer"
gcloud iam service-accounts create orders-api
gcloud iam roles list --filter="name:bigquery"
gcloud secrets create db-password --data-file=-
gcloud secrets versions access latest --secret=db-password

Compute and containers

See Compute Engine, Cloud Run, functions and GKE.

Terminal
gcloud compute instances create web-1 --zone=europe-west1-b \
  --machine-type=e2-small
gcloud compute ssh web-1 --zone=europe-west1-b
gcloud compute instances stop web-1 --zone=europe-west1-b
gcloud compute instances delete web-1 --zone=europe-west1-b

gcloud run deploy orders --source . --region=europe-west1
gcloud run services describe orders --region=europe-west1
gcloud run services update-traffic orders --to-latest --region=europe-west1

gcloud functions deploy hello --gen2 --runtime=nodejs22 \
  --trigger-http --region=europe-west1

gcloud container clusters create-auto demo --region=europe-west1
gcloud container clusters get-credentials demo --region=europe-west1
gcloud artifacts repositories list

Storage and databases

See Cloud Storage, Cloud SQL and BigQuery.

Terminal
gcloud storage buckets create gs://my-unique-bucket --location=europe-west1
gcloud storage cp ./file.txt gs://my-unique-bucket/
gcloud storage ls gs://my-unique-bucket
gcloud storage rm -r gs://my-unique-bucket

gcloud sql instances create shop-db --database-version=POSTGRES_16 \
  --tier=db-custom-1-3840 --region=europe-west1
gcloud sql connect shop-db --user=postgres

bq query --use_legacy_sql=false --dry_run 'SELECT 1'
bq ls

Networking, messaging and operations

See VPC, Pub/Sub and logging.

Terminal
gcloud compute networks create demo-vpc --subnet-mode=custom
gcloud compute firewall-rules create allow-https \
  --network=demo-vpc --allow=tcp:443 --direction=INGRESS
gcloud compute firewall-rules list

gcloud pubsub topics create orders
gcloud pubsub subscriptions create orders-sub --topic=orders
gcloud pubsub topics publish orders --message="hello"

gcloud logging read "severity>=ERROR" --limit=10
gcloud builds submit --tag europe-west1-docker.pkg.dev/my-project-id/repo/app

Choosing a service

You need Reach for
Full control of an OS, special hardware Compute Engine
Stateless HTTP container, scale to zero Cloud Run
Small handler for an event Cloud Run functions
Kubernetes features GKE (Autopilot first)
Files, images, backups, static sites Cloud Storage
Relational data, moderate scale Cloud SQL
Relational data, global scale Spanner
Documents with real-time sync Firestore
Huge key-value throughput Bigtable
Analytics with SQL BigQuery
Decoupled messaging Pub/Sub
Secrets Secret Manager

Defaults and limits worth remembering

Compare with regions and zones and VPC networks.

  • Firewall: an implied rule denies all ingress and allows all egress. Rule priority runs from 0 to 65535, default 1000, and the lowest number wins.
  • Subnets: four addresses in each primary range are reserved, so a /24 has 252 usable addresses.
  • Project deletion: a deleted project can be restored for about 30 days.
  • Cloud Run: default concurrency is 80 requests per instance, and your container must listen on the port given in the PORT environment variable.
  • Pub/Sub: the default acknowledgement deadline is 10 seconds, and delivery is at-least-once.
  • Cloud Storage: bucket names are globally unique and cannot be renamed; signed URLs can last at most seven days.
  • BigQuery: on-demand queries are billed by bytes scanned, so SELECT * and unpartitioned scans cost more.
  • IAM: changes can take a couple of minutes to propagate.
  • Billing: a budget alert notifies you but does not stop spending by itself.

Service chooser (stand-in)

This function turns a few answers into a suggestion, the way the table above does. It is a teaching model with simplified rules, not an official recommender.

JS Stand-in: pick a service

Press Run (or Ctrl + Enter) to see the console output here.

No output.

A defaults lookup (stand-in)

A quick way to rehearse the numbers is a lookup you query and a guess you check. Edit guess and run.

JS Stand-in: check a remembered default

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command sets the project that later gcloud commands use?

    gcloud config set project stores the default project in the active configuration.
  2. 2. You need stateless containers that scale to zero. Which service?

    Cloud Run scales containers with requests and can drop to zero instances.
  3. 3. How many addresses in a subnet's primary range are reserved by Google?

    Four are reserved, so a /24 leaves 252 usable.
  4. 4. Which flag reduces gcloud output to the rows you want?

    --filter selects resources, and --format controls how they are displayed.

Summary

  • Set your identity and project first, then use --format and --filter to shape output.
  • Match the service to the job: Cloud Run for containers, Compute Engine for control, Cloud SQL or Spanner for relational data, BigQuery for analytics.
  • Remember the defaults: lowest firewall priority wins, four reserved subnet addresses, 80 concurrent requests per Cloud Run instance.
  • Confirm numeric limits in the official docs, because they change.

Go back to the start of the track: What Is Cloud Computing?