Files
gcp_solution_architecture_a…/skills/google-cloud-iac-modules/SKILL.md
Jonathan Boniface 135401e41b feat: module follow-ups, and L-07 reworded
- A Check met through a module is met by a value in the code: the modules
  Skill tells the author to set every input a Check depends on.
- scripts/check-terraform-modules.py reports catalogued modules with a newer
  version, and watched modules that can now be used with the pinned provider.
- L-07 no longer mentions a low-carbon location, which led to a Check about a
  region's carbon score that code cannot show. Reworded with the owner's
  approval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 13:34:45 +01:00

57 lines
4.4 KiB
Markdown

---
name: google-cloud-iac-modules
description: >-
Published Terraform modules from the terraform-google-modules organisation
that are known to validate against the pinned hashicorp/google provider: VPC
network with Cloud NAT, private Cloud SQL for PostgreSQL, Cloud Storage
buckets and Cloud KMS. Use when writing Terraform for an Element that one of
these modules covers, to decide whether a module or plain resources fit and to
call the module correctly.
metadata:
scope: deployment guidance, validation results
provider: hashicorp/google 8.6.0
modules: terraform-google-modules
---
# Google Cloud IaC modules
You have this Skill because this Execution opted into published modules: `terraform_modules` is true in your context. Without that, infrastructure code is plain resources and a module call is refused.
A published module replaces several resources that must be wired together with one call that a team already maintains. It also hides the resources a Check is about. Use one only where the first outweighs the second.
## When to use a module
Use a module when **all** of these hold:
1. It is in the table below. Those are the only modules checked against `hashicorp/google` 8.6.0; a test validates each one's example here.
2. It replaces three or more resources that depend on each other, such as a network with its subnets and firewall rules, or a private database with the peering it needs.
3. Every Check on the Elements it covers can be met through one of its inputs. Confirm with `terraform_module`.
Otherwise write the resources directly, from the patterns Skill. A single resource, such as one service account, one topic or one secret, is always written directly.
| For | Module | Version | Reference |
| --- | --- | --- | --- |
| VPC, subnets, firewall rules, and Cloud NAT | `terraform-google-modules/network/google` and `terraform-google-modules/cloud-nat/google` | 18.3.1, 7.1.0 | `references/network.md` |
| Cloud SQL for PostgreSQL on a private address | `terraform-google-modules/sql-db/google//modules/postgresql` with `//modules/private_service_access` | 28.3.0 | `references/cloud-sql.md` |
| A Cloud Storage bucket with retention, lifecycle, encryption and grants | `terraform-google-modules/cloud-storage/google//modules/simple_bucket` | 12.4.1 | `references/cloud-storage.md` |
| A key ring, keys and their grants | `terraform-google-modules/kms/google` | 4.2.1 | `references/kms.md` |
Not usable with this provider version, so write these directly: the load balancer (`lb-http`), Pub/Sub, BigQuery, GKE, log export and the function modules all require `google` below 8. `terraform_module` says so for any module you look up.
## Rules for every module call
- `source` is `terraform-google-modules/<name>/google`, with `//modules/<submodule>` when the table gives one. `version` is one exact version. `terraform_validate` refuses any other source, a Git URL, a local path or a version range.
- Keep `terraform/versions.tf` from the patterns Skill unchanged. A module's own provider requirements are met by it.
- Pass every environment-specific value from a variable, as for resources.
- Before using an input the reference does not show, call `terraform_module` with `find` set to its name.
- Set every input a Check depends on, even when the module's default already gives that value. A Check is verified from a value written in the code; a default left unset can only be argued from the module's documentation, and changes when the module does.
- A module takes names, not always ids: read which one an input wants. Pass another module's output where one depends on the other, so Terraform orders them.
## Checks on an Element a module creates
A Check is still about the resource: "the instance has no public IP address". The code meets it through a module input.
- In `implementation.json`, `address` names the module and the input: `module.database.ip_configuration.ipv4_enabled`.
- When no input sets what a Check needs, the module does not fit that Element. Write its resources directly; do not mark the Check unimplementable, since the resource type does have the setting.
- When validating, read the input's value in the code and confirm with `terraform_module` what that input sets. An input left at its default is judged by the default the lookup shows, and the verdict says the value is a default and not set in the code. A Check is not verifiable only when neither the code nor the module's documentation shows what the resource will get.