[ qdl-001 // available ]
GCPTerraformCIS Benchmark v4Cloud Run v2Postgres 17

GCP Cloud Run
Production Stack.

Security-first Terraform module on the modern GCP stack: Cloud Run v2 with Direct VPC Egress + Cloud SQL (private IP, SSL-only, IAM auth, CMEK) + Secret Manager + scoped IAM. CIS GCP Benchmark v4-aligned. One command apply.

spec.yaml — qdl-001-cloud-run-stack v1.4.1
id qdl-001-cloud-run-stack
cloud Google Cloud Platform
runtime Cloud Run v2 · Direct VPC Egress · GA Q4 2024
database Cloud SQL Postgres 17 · private IP · ENCRYPTED_ONLY
benchmark CIS GCP Foundation v4.0.0 (project-scope controls)
deploy GitHub Actions · Workload Identity Federation
apply time ~12 minutes (47 resources)
idle cost ~$13–22/mo dev tier · scale on demand
last updated 2026-05-15 · v1.4.1
license Commercial · single purchaser · no redistribution
§ A Features

Every box ticked, by default.

The non-negotiables we set so you don't have to remember them in production.

01 · feature

./bootstrap.sh install — one command from blank Google account to live URL

02 · feature

Bundled CLAUDE.md + AGENTS.md + .cursor/rules/ + 3 ADRs + 12 documented AI failure modes — auto-load into Claude Code, Cursor, Codex CLI. Saves the AI-debug-loop tokens you'd otherwise burn.

03 · feature

Aligned with CIS GCP Foundation Benchmark v4.0.0 — security defaults, not afterthoughts

04 · feature

Cloud Run v2 with Direct VPC Egress (GA late 2024 — no idle VPC Connector tax)

05 · feature

Cloud SQL Postgres 17: private IP only, SSL-enforced (ENCRYPTED_ONLY), IAM database auth, pgAudit-ready, max_connections sized for the default tier

06 · feature

CMEK via Cloud KMS for Cloud SQL + Secret Manager (90-day key rotation, ~$0.12/mo, toggleable)

07 · feature

Secret Manager: DB password (40 chars) and full URL mounted as env via secret_key_ref — never in code

08 · feature

Scoped runtime IAM service account — least-privilege from the start

09 · feature

GitHub Actions deploy via WIF (no JSON keys), actions pinned to commit SHAs, minimum permissions

10 · feature

Cross-platform installer (macOS, Linux, Windows via WSL2) + clean teardown script

11 · feature

Built-in FinOps: project billing budget at $50/mo (configurable), alerts at 50/90/100% current + 100% forecasted, routed to the email you give bootstrap.sh (via a Cloud Monitoring notification channel) and to billing-account admins. No surprise bills.

12 · feature

Commercial license, source included, ~700 lines of readable HCL

§ B Specification

The full picture.

What you get

A single Terraform configuration plus a one-command installer that provisions a production-shaped Cloud Run stack on GCP. Unzip, run ./bootstrap.sh install, answer four prompts. Twelve minutes later you have:

  • A Cloud Run v2 service running your container, autoscaling 0→10 (configurable), wired into your VPC via Direct VPC Egress — Google’s recommended pattern since GA in late 2024, replacing the legacy Serverless VPC Access Connector (~$8/mo idle floor)
  • A Cloud SQL Postgres 17 instance reachable only over private IP — no public surface to lock down
  • A real VPC with Cloud NAT for egress and private services peering for Cloud SQL
  • Secret Manager holding the generated DB password and the full Postgres connection URL, mounted into the container as DATABASE_URL
  • A runtime service account scoped to exactly what Cloud Run needs: cloudsql.client, logging.logWriter, monitoring.metricWriter, plus per-secret secretmanager.secretAccessor
  • An uptime check + optional email alert
  • A GitHub Actions workflow that deploys from main using Workload Identity Federation — no service account keys to leak

Why this exists

Most Terraform examples online are toys: public Cloud SQL, default VPCs, service accounts with roles/owner, secrets in env, no encryption-key control, deploy workflows that float actions/checkout@v4 (taghi-jackable). They look fine in a tutorial. They are not what you want serving paying customers.

This is the stack I actually run, hardened against the CIS GCP Foundation Benchmark v4.0.0 for the controls that fall inside a project’s blast radius. It’s the shape — VPC-isolated database, SSL-only connections, customer-managed encryption keys, IAM-scoped to specific resources, signed deploy supply chain — that you’d otherwise spend a week assembling from twelve scattered Hashicorp examples and three blog posts that are subtly wrong.

Saves you AI tokens, not just dev hours

If you customize Terraform with Claude Code, Cursor, Codex, or any other AI assistant — this matters. Most of the spend in an AI-driven Terraform session isn’t the writing; it’s the debug loop. The AI hallucinates the cpu_throttling field (silently accepted, does nothing). terraform plan succeeds. The bill arrives next month. You realize. You ask the AI to fix it. It gets it slightly wrong again. Repeat for deletion_policy = "ABANDON", missing enable_private_path_for_google_cloud_services, the legacy VPC Connector pattern, the count vs for_each re-index trap, secrets in plain env blocks, the connection-pool exhaustion math, the WIF attribute_condition that any tutorial omits.

A typical AI-augmented Terraform session against a stack like this — without guardrails — burns 200K–500K tokens chasing failure modes that are reliably hit, not novel.

This product ships with the guardrails:

  • CLAUDE.md + AGENTS.md — 22 hard rules, auto-loaded by Claude Code, Codex CLI, GitHub Copilot, Devin, and any agent that respects these conventions. The AI reads them once at session start; it stops suggesting the patterns that would have failed the next plan.
  • .cursor/rules/main.mdc — same content, formatted for Cursor’s rule system. alwaysApply: true on every *.tf change.
  • 3 ADRs (Architecture Decision Records) for the load-bearing choices — Direct VPC Egress vs Connector, secret env vs volume mounts, allow-unauth default. When the AI is asked “should we change X?”, it has the documented rationale to defer to instead of arguing for the tutorial pattern.
  • “What AI assistants get wrong about this stack” — 12 specific failure modes with wrong-vs-right HCL side-by-side, each with a citation to the provider issue or GCP doc that explains why. The AI sees this in context and skips the trial-and-error.

Translation: the AI session that would have taken 2 hours of back-and-forth becomes 10 minutes. The cost of this product gets paid back inside one debugging session you don’t have.

Security-first defaults

  • No public surfaces. Cloud SQL has no public IP. There’s nothing to lock down because nothing’s exposed.
  • SSL/TLS enforced on Cloud SQL (ssl_mode = "ENCRYPTED_ONLY"). Plaintext connections are rejected.
  • IAM database auth enabled — grant DB access by GCP identity, not shared passwords.
  • CMEK by default via Cloud KMS, 90-day rotation. ~$0.12/mo. You own the key, you control destruction. Toggle off if your compliance regime doesn’t require it.
  • Hardened Postgres flags per CIS: password_encryption = scram-sha-256, connection/disconnection logging, slow-query visibility, lock-wait logging.
  • 40-character DB password, generated, stored only in Secret Manager. Never in plan output, never in code.
  • Custom VPC with no public surfaces — Cloud SQL private IP only, no permissive default rules. Relies on GCP’s implicit ingress-deny rather than redundant explicit rules that would conflict with future allow rules.
  • Supply-chain hardened CI: GitHub Actions pinned to commit SHA, minimum permissions: scope, deploy concurrency, Workload Identity Federation (no JSON keys).
  • State bucket created with UBLA + public-access-prevention + versioning.

What it costs to run

Defaults are dev-tier, ~$13–22/month at idle:

  • Cloud SQL db-f1-micro + 10GB SSD: ~$10/mo
  • Cloud NAT: ~$0/mo idle (Direct VPC Egress with PRIVATE_RANGES_ONLY doesn’t route through NAT)
  • Cloud KMS (2 CMEK keys): ~$0.12/mo
  • VPC flow logs (50% sample, 5min agg): ~$0.50–$2/mo
  • Cloud Run: scales to zero, ~$0 idle (Direct VPC Egress is pay-per-use, not the old ~$8/mo Connector idle tax)

Production sizing is one variable change away. The module exposes db_tier, min_instances, max_instances, cpu, memory as inputs.

Cost guardrails out of the box

Cloud bills sneak up on you. This stack doesn’t.

  • Project-level billing budget created automatically. Default $50/mo, configurable. Email alerts at 50%, 90%, 100% of actual spend, plus a 100%-forecasted alert that fires before you hit the cap if your trajectory will overshoot.
  • monthly_cost_estimate outputterraform output returns a tier-aware estimate ("~$13–22/month at idle (dev tier defaults)") so you know what you’re signing up for before you raise machine sizes.
  • budget_alert_status output — confirms the budget is wired and reports the email it’ll alert on.
  • Documented cost-down knobs: which variables to flip when you need to drop $5/mo, and which to raise when you outgrow the dev tier. README walks through both directions.
  • bootstrap.sh auto-fills the billing account ID so the budget setup is one prompt (Monthly budget for billing alerts (USD) [50]:), not a console-clicking journey.

If your IAM doesn’t include roles/billing.costsManager on the billing account, set enable_budget_alert = false and the rest of the stack still applies cleanly.

What’s in the box

  • Terraform source: root module, 12 .tf files, ~700 lines of readable, commented HCL
  • bootstrap.sh — cross-platform installer with check and install subcommands. Handles project creation, billing linkage, API enablement, state bucket (UBLA + public-access-prevention + versioning), and terraform apply end-to-end
  • teardown.sh — clean rollback (destroy) or full project deletion (nuke)
  • CLAUDE.md + AGENTS.md + .cursor/rules/main.mdc — agent guardrails that auto-load into Claude Code, Cursor, Codex, Copilot, Devin
  • 3 ADRs documenting load-bearing decisions in Michael Nygard format
  • README with “What AI assistants get wrong” — 12 failure modes with side-by-side HCL
  • docs/wif-setup.md — runnable Workload Identity Federation recipe (the attribute_condition line that’s almost always missing in tutorials, present here)
  • .pre-commit-config.yamlterraform fmt, validate, tflint (Google plugin), trivy, checkov, detect-secrets
  • Runnable examples/basic/ with terraform.tfvars.example
  • GitHub Actions deploy workflow — SHA-pinned actions, minimum permissions:, concurrency-protected
  • Commercial license (one purchaser, unlimited internal use, no redistribution)

Delivered as a zip via Lemon Squeezy email after purchase.

§ C FAQ

Questions buyers ask.

If yours isn't here, email [email protected].

01 Why $129 when there are free Terraform modules on the Hashicorp registry?
The free modules in the registry are toys — public Cloud SQL, default VPC, `roles/owner` service accounts, plaintext env secrets, deploy workflows that float `actions/checkout@v4`. They work in a tutorial. They are not what you want serving paying customers. This stack ships the production shape — VPC-isolated DB, IAM-scoped, CMEK, SSL-only, WIF deploy — that you would otherwise spend a week assembling from twelve scattered Hashicorp examples and three subtly-wrong blog posts. Read every line: it's commercial-licensed source, ~700 lines of HCL, all of it inspectable.
02 Does this work if I already have an existing GCP project?
Yes. `./bootstrap.sh install` works either way: it can create a brand-new project (recommended for cleanliness) or apply against an existing project ID you pass at the prompt. State buckets and APIs are idempotent — re-running on an existing project enables the APIs you don't have and skips the ones you do.
03 How much does it cost to run after apply?
Defaults are dev-tier: ~$13–22/month at idle. Cloud SQL `db-f1-micro` + 10GB SSD is ~$10/mo, Cloud KMS for the two CMEK keys is ~$0.12/mo, VPC flow logs at 50% sampling are ~$0.50–$2/mo, Cloud NAT is ~$0 idle when Direct VPC Egress uses `PRIVATE_RANGES_ONLY`, Cloud Run scales to zero. Production sizing is one variable change away — `db_tier`, `min_instances`, `max_instances`, `cpu`, `memory` are all module inputs. The included billing budget at $50/mo (configurable) alerts at 50/90/100% current + 100% forecasted, so you can't be surprised.
04 What if `terraform apply` fails on my project?
The 14-day refund covers exactly this. If the stack doesn't apply cleanly on a fresh GCP project — meaning a project with billing enabled, a Workload Identity pool set up per the docs, and you running `./bootstrap.sh install` with the four prompts answered correctly — email `[email protected]` within 14 days for a full refund. No questions about your codebase, no debugging session required.
05 Can I customize the Terraform after I buy it?
Yes — that's the whole point. You buy the source, not a SaaS subscription. The module is plain HCL, the variables are named for what they do, and the customer-facing files (`CLAUDE.md`, `AGENTS.md`, `.cursor/rules/main.mdc`) document the load-bearing decisions so an AI assistant working in your repo doesn't break them. Fork freely. The commercial license is single-purchaser, unlimited internal use, no redistribution.
06 Does this work with OpenTofu instead of Terraform?
Probably yes (the HCL is vanilla and doesn't use Terraform-Cloud-specific features), but it's only tested against Terraform 1.9.x. If you run it on OpenTofu and hit a provider compatibility issue, the refund still applies — and I'd appreciate the bug report.
07 How is this different from Google's official Terraform modules?
Google's modules are framework-grade abstractions — they handle every GCP edge case via parameters, which makes them deep and opaque. This stack is opposite: opinionated, narrow, and readable end-to-end in one afternoon. You're paying for the opinions — the specific choices that take a senior platform engineer years to learn the hard way (Direct VPC Egress vs Connector, `cpu_idle = true`, `deletion_policy = ABANDON` on the service-networking connection, the WIF `attribute_condition` line everyone forgets).
08 Why GCP and not AWS or Azure?
Cloud Run is genuinely the best general-purpose container runtime for solo founders: scale-to-zero, no idle base cost, no LB to manage, sane defaults. AWS Fargate + ALB has 4× the cost at idle. Azure Container Apps is competitive on paper but the Terraform provider is less mature. This stack is opinionated about that — the next QDL product is the AWS ECS Fargate stack (Q4 2026), but Cloud Run came first because it's where the price/complexity ratio is currently the lowest.
09 Is there a SaaS or license-key check?
No. Buy once, deploy on as many internal accounts as you want, take the source to your next project. The license is enforced legally (single purchaser, no redistribution), not technically. There is no callout to a license server, no DRM, no expiring keys. The studio does not retain a foothold on your infrastructure.
10 Do you offer support after purchase?
Email-based support for installation issues only, within the 14-day refund window. The product is the artifact; the support model is the documentation. The README has a `What AI assistants get wrong` section with 12 wrong-vs-right HCL examples for the most common failure modes. If you're stuck outside the window, the source is yours to debug.
[ checkout ]

$129 once. Apply this afternoon.

14-day refund if it doesn't apply on a fresh project. No subscription. No upsell.