Loading...
Loading...
Reusable GCP Terraform module patterns for Cloud Run v2, Cloud SQL PostgreSQL, Artifact Registry, VPC, Secret Manager, and Workload Identity Federation. Load when creating or consuming reusable Terraform modules for GCP. Triggers: terraform module, reusable terraform, gcp module, terraform library, cloud run module, cloud sql module, artifact registry module, wif module, terraform module structure.
npx skill4agent add kumaran-is/claude-code-onboarding terraform-module-libraryGCP-primary module patterns for this workspace. Modules cover: Cloud Run v2, Cloud SQL PostgreSQL, Artifact Registry, VPC + Private Services, Secret Manager, Workload Identity Federation.
BEFORE creating a Terraform module:
1. Load terraform-skill for naming conventions and code structure standards
2. Every module MUST have: main.tf, variables.tf, outputs.tf, versions.tf, README.md
3. Every module MUST have tests in tests/ using native terraform test (1.6+) with mock providers
4. Sensitive outputs MUST be marked sensitive = true
5. Dispatch terraform-specialist agent to apply/provision — this skill is for authoring onlymodules/
└── <module-name>/
├── main.tf # Resources only — no provider {}, no backend {}
├── variables.tf # All inputs with description, type, validation
├── outputs.tf # All outputs with description and sensitive flag
├── versions.tf # required_version + required_providers
├── README.md # Usage example + variable/output tables
└── tests/
└── main.tftest.hcl # Native terraform test with mock_provider (1.7+)Which GCP resource are you modularizing?
|
+-- Cloud Run v2 service -> See references/gcp-modules.md § Cloud Run
+-- Cloud SQL (PostgreSQL) -> See references/gcp-modules.md § Cloud SQL
+-- Artifact Registry -> See references/gcp-modules.md § Artifact Registry
+-- VPC + Subnets -> See references/gcp-modules.md § VPC
+-- Secret Manager -> See references/gcp-modules.md § Secret Manager
+-- Workload Identity Fed. -> See references/gcp-modules.md § Workload Identity Federation| File | Load When |
|---|---|
| Writing or reviewing any GCP Terraform module — has full HCL for all 6 modules |
versions.tfgoogle~> 6.0descriptiontypesensitive = truedeletion_protectiontests/main.tftest.hclcommand = applymock_provider "google"README.mdfor_eachcountlifecycle.ignore_changesipv4_enabled = false| Decision | Rationale |
|---|---|
| CI/CD updates the image; Terraform manages config/scaling only. Prevents Terraform drift on every deploy. |
| No public IP; forces Cloud SQL Auth Proxy or private VPC access. Security baseline. |
| Never hardcode or commit passwords. Secret Manager is the source of truth. |
| Stable resource addressing; |
| Cleanup policies on Artifact Registry | Prevents unbounded storage cost from accumulated untagged images. |
WIF | Prevents cross-org token impersonation. |
terraform-skillterraform-specialistdocs/workflows/cloud-run-terraform.mddocs/workflows/terraform-module-development.mdsecurity-reviewer