2.8 KiB
2.8 KiB
name, description, metadata
| name | description | metadata | ||||
|---|---|---|---|---|---|---|
| google-cloud-iac-patterns | Terraform patterns for Google Cloud products that validate against one pinned version of the hashicorp/google provider: Cloud Run services and jobs, Pub/Sub, Cloud Storage, IAM, Secret Manager, Cloud KMS, Cloud SQL, networking, Cloud Scheduler, Artifact Registry, Monitoring and API enablement. Use when writing Terraform for a Google Cloud product, before writing the resource, to start from a pattern whose arguments are known to be in the right place. |
|
Google Cloud IaC patterns
Every pattern here passes terraform validate against hashicorp/google 8.6.0. A test runs that on each of them, so an argument you copy from a pattern is in the right block.
How to use them
- Write
assets/versions.tfto your working copy asterraform/versions.tf, unchanged. It pins the provider version these patterns and theterraform_schematool describe. Declare theproject_idandregionvariables it uses interraform/variables.tf. - For each Element in the Target architecture, read the reference for its product with
load_skill_resourceand start from its pattern. Read only the references for products the Target architecture uses. - Change the pattern to meet the Element's Checks. For a setting the pattern does not show, call
terraform_schemawithfindset to its name before you write it.
| Product | Reference |
|---|---|
| Enabling APIs | references/project-services.md |
| Service accounts and IAM grants | references/iam.md |
| Cloud Run service | references/cloud-run-service.md |
| Cloud Run job | references/cloud-run-job.md |
| Pub/Sub | references/pubsub.md |
| Cloud Storage | references/cloud-storage.md |
| Secret Manager | references/secret-manager.md |
| Cloud KMS | references/kms.md |
| Cloud SQL | references/cloud-sql.md |
| VPC networking | references/networking.md |
| Cloud Scheduler | references/cloud-scheduler.md |
| Artifact Registry | references/artifact-registry.md |
| Cloud Monitoring and Logging | references/monitoring.md |
A product with no reference has no pattern yet: write it from terraform_schema and the product documentation.
Rules that hold for every product
- A Cloud Run service and a Cloud Run job are different resource types with different arguments. A setting of one is not a setting of the other.
references/cloud-run-job.mdlists what a job lacks. - Grant a role with an
_iam_memberresource. An_iam_bindingor_iam_policyresource removes grants made elsewhere. - Give a Google-managed service agent its role before the resource that needs it, with
depends_on. A key, a dead-letter topic and a push subscription all need one. - Set
deletion_protectionfrom a variable on the resources that have it, so a test deployment can be removed.