<< All versions
Google Cloud Platform Architecture & Serverless Delivery (
Skill v1.0.0
currentAutomated scan100/100darknecrocities/skillbuilder/gcp
──Details
PublishedNovember 25, 2026 at 07:20 PM
Content Hashsha256:0d2666945c883fb5...
Git SHAba2df49e0bf4
──Files
Files (1 file, 5.9 KB)
SKILL.md5.9 KBactive
SKILL.md · 142 lines · 5.9 KB
name: gcp description: Google Cloud Platform architecture, Cloud Run serverless deployment, Pub/Sub, Secret Manager, Cloud SQL, and IAM least-privilege security. metadata: version: "1.0.0"
Google Cloud Platform Architecture & Serverless Delivery (/gcp)
Philosophy: Zero static credentials. Containerized serverless by default. Workload Identity over service account keys. Non-root containers. Graceful SIGTERM drains. Exponential backoff on all cloud APIs.
This skill establishes production engineering standards for deploying scalable, cost-efficient, and secure services onto Google Cloud Platform (GCP).
1. Quick Navigation & Progressive Disclosure
| Resource Type | Document | Description | |
|---|---|---|---|
| Reference | references/cloud-run-production-standards.md | Non-root containers, concurrency tuning, liveness/startup probes. | |
| Reference | references/gcp-iam-and-secret-manager.md | Secret Manager mounting, least-privilege service accounts, Workload Identity. | |
| Utility | scripts/verify_gcp_hygiene.py | Audits Dockerfiles, Terraform configs, and scripts for GCP credential leaks and root users. |
2. The Core GCP Architecture Gates
mermaid
flowchart TDA["Source Code & Container"] --> B["Gate 1: Container Security (Non-Root USER 10001)"]B --> C["Gate 2: Ingress & Health Probes (/healthz, SIGTERM drain)"]C --> D["Gate 3: Identity & Secrets (Workload Identity, Secret Manager)"]D --> E["Gate 4: Serverless Deployment (Cloud Run, Cloud Functions v2)"]E --> F["Gate 5: Managed Telemetry (Cloud Logging, Cloud Trace)"]F --> G["Gate 6: Single-Slot Cloud SQL/GCS Backup & Deletion Protection"]
- Gate 1: Container Hardening: Cloud Run workloads must execute in multi-stage, scratch/distroless or alpine base containers running as non-root (
USER 10001). - Gate 2: Ingress & Health Check Probes: Cloud Run services must expose
/healthzor/statusstartup and liveness probes. - Gate 3: Secret & Identity Hygiene: Prohibit static service account JSON keys. Enforce Workload Identity Federation and retrieve sensitive runtime secrets from GCP Secret Manager.
- Gate 4: Graceful Drainage: Handle
SIGTERMsignals cleanly with a 10-second drain window before Cloud Run instance scale-down. - Gate 5: Managed Telemetry: Emit structured JSON logs with
logging.googleapis.com/tracecorrelation fields for Cloud Logging. - Gate 6: Deduplicated Cloud SQL / GCS Backups & Deletion Protection:
- Enforce
deletion_protection = trueon Cloud SQL / Spanner instances and soft-delete retention on GCS buckets. - Maintain a single SHA-256 content-hashed backup entry in
.backups/backup_manifest.json(manage_deduplicated_backup.py) before schema migrations so concurrent agents never trigger duplicate export spam. - Always halt and warn the user first before setting
deletion_protection = false,force_destroy = true, or deleting GCS buckets/Cloud SQL databases.
2. Cloud Run & Serverless Deployment Standards
2.1 Multi-Stage Cloud Run Dockerfile
dockerfile
# Build stageFROM node:20-alpine AS builderWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .RUN npm run build# Production runner stageFROM node:20-alpine AS runnerWORKDIR /appENV NODE_ENV=productionENV PORT=8080RUN addgroup -g 10001 -S nonroot && adduser -u 10001 -S nonroot -G nonrootCOPY --from=builder /app/dist ./distCOPY --from=builder /app/node_modules ./node_modulesCOPY --from=builder /app/package.json ./package.jsonUSER 10001EXPOSE 8080CMD ["node", "dist/server.js"]
2.2 Graceful SIGTERM Shutdown in Node.js / Express
typescript
import express from "express";const app = express();const port = parseInt(process.env.PORT || "8080", 10);app.get("/healthz", (_req, res) => {res.status(200).send("OK");});const server = app.listen(port, () => {console.log(`Cloud Run service running on port ${port}`);});process.on("SIGTERM", () => {console.log("SIGTERM received. Draining connections before shutdown...");server.close(() => {console.log("HTTP server closed. Exiting process.");process.exit(0);});// Force shutdown after 10s timeoutsetTimeout(() => {console.error("Forced process termination after timeout.");process.exit(1);}, 10_000).unref();});
3. Secret Manager & Workload Identity
Never commit GCP service account keys (credentials.json). In Cloud Run or GKE, Application Default Credentials (ADC) seamlessly authenticate against GCP services:
python
from google.cloud import secretmanagerdef get_secret(project_id: str, secret_name: str, version: str = "latest") -> str:"""Retrieves secret payload securely using Application Default Credentials (ADC)."""client = secretmanager.SecretManagerServiceClient()resource_name = f"projects/{project_id}/secrets/{secret_name}/versions/{version}"response = client.access_secret_version(request={"name": resource_name})return response.payload.data.decode("UTF-8")
4. GCP Architecture Verification CLI
Audit your repository for GCP misconfigurations, exposed service account keys, and missing Cloud Run health probes:
bash
python3 skills/gcp/scripts/verify_gcp_hygiene.py --path . --strict
Audited Rules:
GCP-EXPOSED-SERVICE-ACCOUNT-KEY: Detects committed service account private keys ("type": "service_account").GCP-MISSING-HEALTH-CHECK: Warns if service entrypoints lack/healthzor liveness probes.GCP-CONTAINER-ROOT-USER: Flags Dockerfiles missing non-rootUSERdirectives.GCP-HARDCODED-PROJECT-ID: Detects hardcoded GCP project numbers or IDs in code.GCP-DISABLED-DELETION-PROTECTION: Flagsdeletion_protection = falseorforce_destroy = trueon Cloud SQL/GCS resources without explicit user confirmation (@user-approved-deletion).