Infrastructure code is plain resources by default. An Execution may opt in with terraform_modules; the deployment default is TERRAFORM_MODULES, off. - A module is accepted only from the registry namespaces the provider bundle lists (terraform-google-modules), at one exact version. Any other source is refused before Terraform runs; until now nothing stopped generated code naming any source for terraform init to download. - terraform_module looks up a module's inputs, outputs and submodules from the registry and says when it cannot be used with the pinned provider. - skills/google-cloud-iac-modules: when a module fits, and four modules with examples a test validates against hashicorp/google 8.6.0. - Opted in, the IaC author and validator get the Skill and the lookup. Not opted in, they get neither and a module block is refused in code. - A Change request follows its Baseline. execution.json records the choice. - case-07 runs case 03's request with modules opted into. Azure (aztfm) and AWS (terraform-aws-modules) sources are recorded in the plan for when those Cloud providers are added. No case has run with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.9 KiB
1.9 KiB
VPC network and Cloud NAT
A custom-mode VPC with its subnets and firewall rules, and outbound internet through Cloud NAT. Replaces a network, its subnetworks, a router, a NAT and each firewall rule.
subnetsis a list of objects whose values are all strings, including"true"forsubnet_private_access.network_nameis a name. Other resources wantmodule.network.network_self_linkornetwork_id;subnetsis an output map keyed"<region>/<subnet_name>".ingress_rulesreplaces the deprecatedfirewall_rules.- The NAT module creates its router when
create_router = true, and then needsnetwork. - Set
nameon the NAT. Left unset it gets a random suffix.
variable "project_id" {
type = string
description = "Project to deploy into."
}
variable "region" {
type = string
description = "Region for regional resources."
}
module "network" {
source = "terraform-google-modules/network/google"
version = "18.3.1"
project_id = var.project_id
network_name = "workload"
routing_mode = "REGIONAL"
subnets = [
{
subnet_name = "workload"
subnet_ip = "10.10.0.0/24"
subnet_region = var.region
subnet_private_access = "true"
subnet_flow_logs = "true"
}
]
ingress_rules = [
{
name = "allow-health-checks"
source_ranges = ["130.211.0.0/22", "35.191.0.0/16"]
allow = [
{
protocol = "tcp"
ports = ["8080"]
}
]
}
]
}
module "nat" {
source = "terraform-google-modules/cloud-nat/google"
version = "7.1.0"
project_id = var.project_id
region = var.region
name = "workload-nat"
create_router = true
router = "workload-router"
network = module.network.network_self_link
log_config_enable = true
log_config_filter = "ERRORS_ONLY"
}