๐ค
Google Cloud
Deploy, monitor, and manage GCP services with battle-tested patterns.
ๅฎๅ
จ้่ฟ
๐ฌPrompt
ๆ่ฝ่ฏดๆ
name: Google Cloud description: Deploy, monitor, and manage GCP services with battle-tested patterns. metadata: {"clawdbot":{"emoji":"๐","requires":{"anyBins":["gcloud"]},"os":["linux","darwin","win32"]}}
Google Cloud Production Rules
Cost Traps
- Stopped Compute Engine VMs still pay for persistent disks and static IPs โ delete disks or use snapshots for long-term storage
- Cloud NAT charges per VM and per GB processed โ use Private Google Access for GCP API traffic instead
- BigQuery on-demand pricing charges for bytes scanned, not rows returned โ partition tables and use
LIMITin dev, butLIMITdoesn't reduce scan cost in prod - Preemptible VMs save 80% but can be terminated anytime โ only for fault-tolerant batch workloads
- Egress to internet costs, egress to same region is free โ keep resources in same region, use Cloud CDN for global distribution
Security Rules
- Service accounts are both identity and resource โ one service account can impersonate another with
roles/iam.serviceAccountTokenCreator - IAM policy inheritance: Organization โ Folder โ Project โ Resource โ deny policies at org level override allows below
- VPC Service Controls protect against data exfiltration โ but break Cloud Console access if not configured with access levels
- Default Compute Engine service account has Editor role โ create dedicated service accounts with least privilege
- Workload Identity Federation eliminates service account keys โ use for GitHub Actions, GitLab CI, external workloads
Networking
- VPC is global, subnets are regional โ unlike AWS, single VPC can span all regions
- Firewall rules are allow-only by default โ implicit deny all ingress, allow all egress. Add explicit deny rules for egress control
- Private Google Access is per-subnet setting โ enable on every subnet that needs to reach GCP APIs without public IP
- Cloud Load Balancer global vs regional โ global for multi-region, but regional is simpler and cheaper for single region
- Shared VPC separates network admin from project admin โ host project owns network, service projects consume it
Performance
- Cloud Functions gen1 has 9-minute timeout โ gen2 (Cloud Run based) allows 60 minutes
- Cloud SQL connection limits vary by instance size โ use connection pooling or Cloud SQL Auth Proxy
- Firestore/Datastore hotspotting on sequential IDs โ use UUIDs or reverse timestamps for document IDs
- GKE Autopilot simplifies but limits โ no DaemonSets, no privileged containers, no host network
- Cloud Storage single object limit is 5TB โ use compose for larger, parallel uploads for faster
Monitoring
- Cloud Logging retention: 30 days default, _Required bucket is 400 days โ create custom bucket with longer retention for compliance
- Cloud Monitoring alert policies have 24-hour auto-close โ incident disappears even if issue persists, configure notification channels for re-alert
- Error Reporting groups by stack trace โ same error with different messages creates duplicates
- Cloud Trace sampling is automatic โ may miss rare errors, increase sampling rate for debugging
- Audit logs: Admin Activity always on, Data Access off by default โ enable Data Access logs for security compliance
Infrastructure as Code
- Terraform google provider requires project ID everywhere โ use
google_projectdata source or variables, never hardcode gcloudcommands are imperative โ use Deployment Manager or Terraform for reproducible infra- Cloud Build triggers on push but IAM permissions on first run confusing โ grant Cloud Build service account necessary roles before first deploy
- Project deletion has 30-day recovery period โ but project ID is globally unique forever, can't reuse
- Labels propagate to billing โ use consistent labeling for cost allocation:
env,team,service
IAM Best Practices
- Primitive roles (Owner/Editor/Viewer) are too broad โ use predefined roles, create custom for least privilege
- Service account keys are security liability โ use Workload Identity, impersonation, or attached service accounts instead
roles/iam.serviceAccountUserlets you run as that SA โ equivalent to having its permissions, grant carefully- Organization policies restrict what projects can do โ
constraints/compute.vmExternalIpAccessblocks public VMs org-wide
ๅฆไฝไฝฟ็จใGoogle Cloudใ๏ผ
- ๆๅผๅฐ้พ่พAI๏ผWeb ๆ iOS App๏ผ
- ็นๅปไธๆนใ็ซๅณไฝฟ็จใๆ้ฎ๏ผๆๅจๅฏน่ฏๆกไธญ่พๅ ฅไปปๅกๆ่ฟฐ
- ๅฐ้พ่พAI ไผ่ชๅจๅน้ ๅนถ่ฐ็จใGoogle Cloudใๆ่ฝๅฎๆไปปๅก
- ็ปๆๅณๆถๅ็ฐ๏ผๆฏๆ็ปง็ปญๅฏน่ฏไผๅ