How terraform-google-modules/terraform-google-network works
Project Type and Purpose
• This is an open-source Terraform module (“terraform-google-network”) for provisioning and managing GCP VPC networks (and related resources) in a modular, reusable fashion.
• It defines a “root” module (main.tf + variables.tf + outputs.tf) which delegates to a number of sub-modules (vpc, subnets, routes, firewall-rules, etc.).
• It also includes examples, tests (unit-style fixtures and Go-based integration tests), CI/CD configuration (GitHub Actions, Cloud Build), and documentation.
Top-Level Components
a. Core Module
• main.tf, variables.tf, outputs.tf, metadata.yaml – orchestrates creation of a VPC and its subcomponents
• helpers/ (e.g. migrate.py) – scripts supporting module lifecycle or migrations
b. Sub-Modules (modules/)
• vpc
• subnets & subnets-beta
• routes & routes-beta
• firewall-rules
• network-firewall-policy
• hierarchical-firewall-policy
• private-service-connect
• vpc-serverless-connector-beta
• network-connectivity-center
Each encapsulates one logical resource group, with its own inputs, outputs, versions, metadata.
c. Examples (examples/)
• A series of folders demonstrating different use cases (basic_auto_mode, basic_custom_mode, firewall_logging, multi_vpc, etc.).
• Each contains its own Terraform configs: main.tf, variables.tf, outputs.tf, versions.tf.
d. Testing
• test/fixtures – Terraform snippets and expected outputs for unit-style validation.
• test/integration – Go test suites invoking Terraform to spin up real infrastructure in GCP.
• test/setup – supporting Terraform stack for integration harness (IAM, service account, etc.).
e. CI/CD
• .github/workflows/*.yaml – lint, stale-issue automation, release automation, renovate config.
• build/*.cloudbuild.yaml & Makefile – Cloud Build pipelines for linting, validation, release.
f. Documentation & Governance
• README.md, docs/, CHANGELOG.md, CONTRIBUTING.md, CODEOWNERS, LICENSE.
External Dependencies & Data Flows
• Terraform CLI interacts with the Google Cloud Terraform Provider to make GCP API calls (Compute Engine, VPC, IAM).
• CI pipelines (GitHub Actions / Cloud Build) run Terraform commands and tests, report back to GitHub.
• Tests (Go) invoke Terraform, read outputs, verify expectations.
• Examples demonstrate consumption of the published module (registry source).
Key Architectural Patterns
• Modular decomposition: each sub-module encapsulates one GCP resource.
• Layered abstraction: root module composes sub-modules; examples consume root module.
• Test-as-code: fixtures for unit tests; integration tests in Go.
• GitOps/CI-as-code: YAML pipelines for linting, testing, release management.