Skip to content

Instantly share code, notes, and snippets.

View sruffilli's full-sized avatar

Simone Ruffilli sruffilli

  • Google
  • Milan, IT
View GitHub Profile
$ find . -name '*.tf' -exec grep -H -i "glb" {} \;
./blueprints/apigee/bigquery-analytics/outputs.tf: value = module.glb.address
./blueprints/apigee/bigquery-analytics/main.tf:module "glb" {
./blueprints/apigee/bigquery-analytics/main.tf: name = "glb"
./blueprints/apigee/hybrid-gke/outputs.tf: description = "GLB IP address."
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/outputs.tf: description = "GLB IP address."
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/outputs.tf: value = module.glb.address
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_nb.tf:module "glb" {
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_nb.tf: name = "glb"
./blueprints/serverless/api-gateway/outputs.tf: value = module.glb.address
$ find . -name '*.tf' -exec grep -H -i "ilb" {} \;
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/onprem.tf:module "onprem_ilb_l7" {
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/onprem.tf: name = "ilb"
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_sb.tf:module "apigee_ilb_l7" {
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_sb.tf: name = "apigee-ilb"
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_sb.tf: ip_address = module.onprem_ilb_l7.address
./blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_sb.tf: target_service = module.apigee_ilb_l7.forwarding_rule.id
./blueprints/serverless/cloud-run-corporate/outputs.tf: value = var.custom_domain != null ? module.ilb-l7[0].address : "none"
./blueprints/serverless/cloud-run-corporate/main.tf:# L7 I
Name Value Description
External IP 198.51.100.1 External IP address
Internal IP 10.0.0.2/24 Internal IP address, which will be configured on a loopback interface
On premises CIDR 10.0.0.0/24 Onprem network CIDR
On premises Private DNS Zone onprem.example.com On premises Private DNS Zone
Name Value Description
Cloud Private DNS Zone gcp.example.com On premises Private DNS Zone
Cloud VPN Gateway INTERFACE0 35.242.88.135 IP for the VPN Gateway INTERFACE0, generated when creating the VPN Gateway
Cloud VPN Gateway INTERFACE1 35.220.106.20 IP for the VPN Gateway INTERFACE1, generated when creating the VPN Gateway
Project id vpn-lab-foobar-0 Project ID for the existing GCP project where the environment will be set up.
Region europe-west1 Deployment region for the GCP environment
VPC CIDR 10.0.1.0/24 GCP network CIDR
VPC vpc Name for the GCP VPC

A descriptive approach to Terraform

Preamble

As your Terraform codebase grows in size and reach, you might find yourself in one of these common scenarios:

  • enabling contributions from specific teams (e.g. NetOps to create new subnets or firewall rules, or the Logging and Monitoring team to configure new alerts) can be difficult since Terraform knowledge is not widespread across teams
  • the repetitive creation of resources of a given kind (e.g. firewall rules, subnets, projects) is scattered throughout your codebase, making it complex to get a clear picture of their structure
  • sticking to a monolithic, end-to-end approach for a large infrastructure (i.e. describing your whole infrastructure in a large terraform module/state) makes for a slower, less maintainable codebase, which doesn’t mirror the different speeds at which your infra evolves (e.g. core infrastructure vs firewall rules)