cheat-sheets

Google Cloud

Google Cloud from a self-hoster’s point of view: the free e2-micro VM, Cloud Storage for backups, firewall rules, Cloud DNS, service accounts and budgets. For generic CLI usage see gcloud (Google Cloud CLI); to compare providers see Cloud-Provider Comparison.

Documentation: gcloud reference · Free Tier features · Terraform Google provider (see Terraform)

Verification: flags were checked against the gcloud reference pages and free-tier terms against the Google Cloud Free Tier page (November 2026). No command was run against a project. Items marked (unverified) were not confirmed.

Services a Self-Hoster Uses #

NEEDSERVICENOTES
Virtual machineCompute EngineOne free e2-micro, see below
Object storageCloud StorageBackups, static files
FirewallVPC firewall rulesApplied by network tag or service account
Disk snapshotsSnapshot schedulesResource policy attached to a disk
DNSCloud DNSManaged zones are billed monthly
Containers without serversCloud RunScales to zero
Access controlIAM and service accountsAvoid downloaded keys where possible
Cost controlBilling budgetsAlerts only, they do not stop spending

Free Tier #

Source: Free Tier features. Google can change terms with 30 days’ notice and a billing account is required.

PRODUCTFREE USAGE
Compute Engine1 non-preemptible e2-micro per month in us-west1, us-central1 or us-east1
Persistent disk30 GB-months standard disk
Network egress1 GB per month from North America (excluding China and Australia)
Cloud Storage5 GB regional storage (US regions), 5,000 Class A and 50,000 Class B operations, 100 GB egress
Cloud Run2 million requests, 360,000 GB-seconds, 180,000 vCPU-seconds, 1 GB egress

New accounts may also receive trial credit; check the current offer on the Free Program page.

Compute Engine #

COMMANDDESCRIPTION
gcloud compute instances create <NAME> --machine-type e2-micro --image-family <FAMILY> --image-project <PROJECT> --zone <ZONE> --tags <TAG>Create a VM (list families with gcloud compute images list)
gcloud compute instances listList VMs
gcloud compute instances stop <NAME> --zone <ZONE>Stop a VM
gcloud compute instances delete <NAME> --zone <ZONE>Delete a VM (data on boot disk is deleted by default)
gcloud compute ssh <NAME> --zone <ZONE>SSH in (see gcloud (Google Cloud CLI))

Firewall #

COMMANDDESCRIPTION
gcloud compute firewall-rules create <NAME> --allow tcp:22 --source-ranges 203.0.113.10/32 --target-tags <TAG> --direction INGRESSAllow SSH from one address to tagged VMs
gcloud compute firewall-rules listList rules

The default network ships with rules that allow SSH and RDP from anywhere. Delete or narrow them, or use a VPN such as WireGuard or Tailscale.

Snapshots #

COMMANDDESCRIPTION
gcloud compute disks snapshot <DISK> --zone <ZONE>One-off snapshot
gcloud compute resource-policies create snapshot-schedule <NAME> --region <REGION> --daily-schedule --start-time 03:00 --max-retention-days 7 --on-source-disk-delete keep-auto-snapshotsDaily schedule with retention (attach it to a disk afterwards; the attach command is (unverified))

Cloud Storage #

COMMANDDESCRIPTION
gcloud storage buckets create gs://<BUCKET> --location <LOCATION> --default-storage-class <CLASS> --uniform-bucket-level-access --public-access-preventionCreate a private bucket
gcloud storage cp <FILE> gs://<BUCKET>/Copy to a bucket
gcloud storage rsync <DIR> gs://<BUCKET>/<PREFIX>Sync a directory (add --delete-unmatched-destination-objects only to mirror deletions, flag unverified)
gcloud storage buckets update gs://<BUCKET> --lifecycle-file lifecycle.jsonApply lifecycle rules

Lifecycle rule moving objects to Archive after 90 days and deleting after a year (lifecycle.json, format from the Cloud Storage lifecycle docs):

json
{
  "rule": [
    {
      "action": { "type": "SetStorageClass", "storageClass": "ARCHIVE" },
      "condition": { "age": 90 }
    },
    {
      "action": { "type": "Delete" },
      "condition": { "age": 365 }
    }
  ]
}

Classes are STANDARD, NEARLINE, COLDLINE and ARCHIVE. Use a bucket with restic or rclone.

Service Accounts and IAM #

COMMANDDESCRIPTION
gcloud iam service-accounts create <NAME> --display-name <TEXT>Create a service account
gcloud projects add-iam-policy-binding <PROJECT_ID> --member serviceAccount:<NAME>@<PROJECT_ID>.iam.gserviceaccount.com --role <ROLE>Grant a project role (command unverified here, see the gcloud (Google Cloud CLI) sheet)
gcloud iam service-accounts keys create key.json --iam-account <NAME>@<PROJECT_ID>.iam.gserviceaccount.comDownload a key file (a long-lived secret, avoid where possible)
gcloud auth listShow active accounts

Prefer attaching a service account to the VM, or workload identity federation for CI, over key files. Never commit key.json.

DNS #

COMMANDDESCRIPTION
gcloud dns managed-zones create <ZONE_NAME> --dns-name example.com. --description <TEXT>Create a zone (note the trailing dot)
gcloud dns record-sets create www.example.com. --zone <ZONE_NAME> --type A --rrdatas 203.0.113.10 --ttl 300Add a record

Cloud Run #

COMMANDDESCRIPTION
gcloud run deploy <SERVICE> --image <IMAGE> --region <REGION> --no-allow-unauthenticatedDeploy a container privately (use --allow-unauthenticated for a public service)

Budgets #

COMMANDDESCRIPTION
gcloud billing budgets create --billing-account <BILLING_ACCOUNT_ID> --display-name <NAME> --budget-amount 10GBP --threshold-rule percent=0.5 --threshold-rule percent=1.0Alert at 50% and 100% of a budget (amount format unverified)

Budgets alert but do not cap spending.

Pitfalls #

PITFALLDETAIL
Free VM is region-lockedOnly the three US regions qualify, so latency from Europe is high
Wrong zone or classAn e2-small or a disk in another region is billed in full
Static external IPsCharges apply for reserved or in-use addresses; rates (unverified, the pricing page did not render)
EgressOnly 1 GB per month is free from the VM, then charged per GB
Service account keysLeaked keys give full access to their roles
BudgetsAlert only, no automatic stop

See Also #

Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.