$ show terraform-google-modules/terraform-google-network
This is a comprehensive Terraform module library for provisioning Google Cloud networking infrastructure. It provides building blocks for VPCs, subnets, routes, firewall rules (classic and policy-based), network peering, Private Service Connect (consumer, producer, endpoints), Network Connectivity Center hubs/spokes, and higher-level foundation patterns (shared VPC, hub-and-spoke). The architecture is modular: the root module orchestrates core resources while 30+ submodules handle specific concerns (e.g., firewall-rules, subnets-beta, network-firewall-policy). Each submodule has its own variables, outputs, and version constraints, making them independently consumable. Extensive integration tests in Go (using cloud-foundation-toolkit) validate correct behavior against real GCP projects. The module is actively maintained with frequent releases (v18.3.0) and follows Google Cloud Foundation Toolkit conventions, but exhibits some technical drift: deprecated variables remain, beta submodules may lag behind GA, and many examples pin older Terraform/provider versions.
The LLM identified 3 files worth highlighting for reuse:
Creates subnets from a map variable keyed by region/name. Accepts secondary ranges, flow logs, purpose, role, and IPv6 options. Uses for_each on the subnet map with resource-level count for conditional flow_logs. The design is clean and extensible; adding new subnet features (e.g., ip_collection) requires only expanding the variable schema and adding a single dynamic block. This pattern is directly reusable for any Terraform project that needs to manage a variable number of similarly-structured resources.
Manages classic GCP firewall rules using separate ingress_rules and egress_rules maps, each supporting allow/deny rules with logging. Deprecated firewall_rules variable is still supported by converting to the new format. Uses dynamic blocks for allow, deny, and log_config. The decoupling of ingress and egress into distinct maps simplifies rule configuration and reduces errors. The deprecation pattern (mark old variable as deprecated, transform inputs) is a robust way to manage API churn in Terraform modules.
Creates a GCP VPC with many optional features controlled by boolean variables (auto_create_subnetworks, delete_default_routes_on_create, enable_ipv6_ula, network_profile, bgp_best_selection, etc.). Uses conditional resource creation via count and inline logic to set fields like routing_mode and mtu. The pattern of exposing a rich set of feature flags while maintaining a clean interface demonstrates good Terraform module design. It can be extracted as a standalone VPC module.