Community by FindUtils

Google Cloud Platform Patterns

Google Cloud Platform patterns with Cloud Run, Cloud Functions, Cloud Storage, BigQuery, and Pub/Sub for production workloads.

Claude CodeCursorGitHub CopilotWindsurfClineCodex / OpenAIGemini CLI
Updated 2026-04-05
CLAUDE.md
# Google Cloud Platform Patterns

You are an expert in Google Cloud Platform, serverless architecture, and GCP best practices.

Cloud Run:
- Deploy containers that scale to zero: ideal for APIs and web services
- Use multi-stage Docker builds to minimize image size
- Set min-instances to 1 for latency-sensitive services (avoids cold start)
- Configure concurrency per container: default 80, tune based on workload
- Use Cloud Run services for HTTP, Cloud Run jobs for batch processing

Cloud Functions:
- Use for event-driven workloads: Pub/Sub triggers, Cloud Storage events, HTTP
- Gen2 functions run on Cloud Run infrastructure (better scaling, longer timeouts)
- Keep functions focused: one trigger, one responsibility
- Set appropriate memory and timeout limits
- Use Secret Manager for credentials (never hardcode or use env vars for secrets)

Data Services:
- Cloud Storage: object storage with multiple storage classes (Standard, Nearline, Coldline, Archive)
- BigQuery: serverless data warehouse, pay per query, excellent for analytics
- Firestore: NoSQL document database with real-time sync and offline support
- Cloud SQL: managed MySQL/PostgreSQL with automatic backups and HA
- Memorystore: managed Redis/Memcached for caching

Messaging:
- Pub/Sub for async messaging: at-least-once delivery, ordered if needed
- Use push subscriptions for Cloud Run/Functions integration
- Use pull subscriptions for custom consumers with flow control
- Set message retention and dead letter topics for failed messages
- Use Cloud Tasks for guaranteed task execution with scheduling

IAM and Security:
- Use service accounts for service-to-service auth (not user credentials)
- Follow least privilege: grant only needed roles
- Use Workload Identity Federation for external auth (GitHub Actions, AWS)
- Enable VPC Service Controls for sensitive data perimeters
- Use Organization Policies to enforce security constraints across projects

Add to your project root CLAUDE.md file, or append to an existing one.

Tags

gcpcloud-runbigquerypub-subserverless