1---
2name: google-cloud
3description: Deploy, monitor, and manage GCP services with battle-tested patterns.
4metadata:
5 source: https://skillmd.com/skills/modbender/google-cloud
6 clawdbot:
7 emoji: 🌐
8 requires:
9 anyBins:
10 - gcloud
11 os:
12 - linux
13 - darwin
14 - win32
15---
16
17# Google Cloud Production Rules
18
19## Cost Traps
20- Stopped Compute Engine VMs still pay for persistent disks and static IPs — delete disks or use snapshots for long-term storage
21- Cloud NAT charges per VM and per GB processed — use Private Google Access for GCP API traffic instead
22- BigQuery on-demand pricing charges for bytes scanned, not rows returned — partition tables and use `LIMIT` in dev, but `LIMIT` doesn't reduce scan cost in prod
23- Preemptible VMs save 80% but can be terminated anytime — only for fault-tolerant batch workloads
24- Egress to internet costs, egress to same region is free — keep resources in same region, use Cloud CDN for global distribution
25
26## Security Rules
27- Service accounts are both identity and resource — one service account can impersonate another with `roles/iam.serviceAccountTokenCreator`
28- IAM policy inheritance: Organization → Folder → Project → Resource — deny policies at org level override allows below
29- VPC Service Controls protect against data exfiltration — but break Cloud Console access if not configured with access levels
30- Default Compute Engine service account has Editor role — create dedicated service accounts with least privilege
31- Workload Identity Federation eliminates service account keys — use for GitHub Actions, GitLab CI, external workloads
32
33## Networking
34- VPC is global, subnets are regional — unlike AWS, single VPC can span all regions
35- Firewall rules are allow-only by default — implicit deny all ingress, allow all egress. Add explicit deny rules for egress control
36- Private Google Access is per-subnet setting — enable on every subnet that needs to reach GCP APIs without public IP
37- Cloud Load Balancer global vs regional — global for multi-region, but regional is simpler and cheaper for single region
38- Shared VPC separates network admin from project admin — host project owns network, service projects consume it
39
40## Performance
41- Cloud Functions gen1 has 9-minute timeout — gen2 (Cloud Run based) allows 60 minutes
42- Cloud SQL connection limits vary by instance size — use connection pooling or Cloud SQL Auth Proxy
43- Firestore/Datastore hotspotting on sequential IDs — use UUIDs or reverse timestamps for document IDs
44- GKE Autopilot simplifies but limits — no DaemonSets, no privileged containers, no host network
45- Cloud Storage single object limit is 5TB — use compose for larger, parallel uploads for faster
46
47## Monitoring
48- Cloud Logging retention: 30 days default, \_Required bucket is 400 days — create custom bucket with longer retention for compliance
49- Cloud Monitoring alert policies have 24-hour auto-close — incident disappears even if issue persists, configure notification channels for re-alert
50- Error Reporting groups by stack trace — same error with different messages creates duplicates
51- Cloud Trace sampling is automatic — may miss rare errors, increase sampling rate for debugging
52- Audit logs: Admin Activity always on, Data Access off by default — enable Data Access logs for security compliance
53
54## Infrastructure as Code
55- Terraform google provider requires project ID everywhere — use `google_project` data source or variables, never hardcode
56- `gcloud` commands are imperative — use Deployment Manager or Terraform for reproducible infra
57- Cloud Build triggers on push but IAM permissions on first run confusing — grant Cloud Build service account necessary roles before first deploy
58- Project deletion has 30-day recovery period — but project ID is globally unique forever, can't reuse
59- Labels propagate to billing — use consistent labeling for cost allocation: `env`, `team`, `service`
60
61## IAM Best Practices
62- Primitive roles (Owner/Editor/Viewer) are too broad — use predefined roles, create custom for least privilege
63- Service account keys are security liability — use Workload Identity, impersonation, or attached service accounts instead
64- `roles/iam.serviceAccountUser` lets you run as that SA — equivalent to having its permissions, grant carefully
65- Organization policies restrict what projects can do — `constraints/compute.vmExternalIpAccess` blocks public VMs org-wide