From 8666553e0912af92e072eef9fa8c75e754af6f1b Mon Sep 17 00:00:00 2001 From: rglenn-accenture Date: Thu, 4 Mar 2021 15:50:14 -0500 Subject: [PATCH] feat: Add support for export_local_subnet_routes_with_public_ip and export_peer_subnet_routes_with_public_ip (#255) --- modules/network-peering/README.md | 2 ++ modules/network-peering/main.tf | 7 +++++++ modules/network-peering/variables.tf | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/modules/network-peering/README.md b/modules/network-peering/README.md index 2c2c3900..ca95ffe8 100644 --- a/modules/network-peering/README.md +++ b/modules/network-peering/README.md @@ -49,7 +49,9 @@ module "peering-a-c" { | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | export\_local\_custom\_routes | Export custom routes to peer network from local network. | `bool` | `false` | no | +| export\_local\_subnet\_routes\_with\_public\_ip | Export custom routes to peer network from local network (defaults to true; causes the Local Peering Connection to align with the [provider default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_network_peering#export_subnet_routes_with_public_ip), and the Remote Peering Connection to be opposite the provider default). | `bool` | `true` | no | | export\_peer\_custom\_routes | Export custom routes to local network from peer network. | `bool` | `false` | no | +| export\_peer\_subnet\_routes\_with\_public\_ip | Export custom routes to local network from peer network (defaults to false; causes the Local Peering Connection to align with the [provider default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_network_peering#import_subnet_routes_with_public_ip), and the Remote Peering Connection to be opposite the provider default). | `bool` | `false` | no | | local\_network | Resource link of the network to add a peering to. | `string` | n/a | yes | | module\_depends\_on | List of modules or resources this module depends on. | `list(any)` | `[]` | no | | peer\_network | Resource link of the peer network. | `string` | n/a | yes | diff --git a/modules/network-peering/main.tf b/modules/network-peering/main.tf index d352798f..7fb49f80 100644 --- a/modules/network-peering/main.tf +++ b/modules/network-peering/main.tf @@ -30,6 +30,7 @@ resource "random_string" "network_peering_suffix" { special = false length = 4 } + resource "google_compute_network_peering" "local_network_peering" { provider = google-beta name = local.local_network_peering_name @@ -38,6 +39,9 @@ resource "google_compute_network_peering" "local_network_peering" { export_custom_routes = var.export_local_custom_routes import_custom_routes = var.export_peer_custom_routes + export_subnet_routes_with_public_ip = var.export_local_subnet_routes_with_public_ip + import_subnet_routes_with_public_ip = var.export_peer_subnet_routes_with_public_ip + depends_on = [null_resource.module_depends_on] } @@ -49,6 +53,9 @@ resource "google_compute_network_peering" "peer_network_peering" { export_custom_routes = var.export_peer_custom_routes import_custom_routes = var.export_local_custom_routes + export_subnet_routes_with_public_ip = var.export_peer_subnet_routes_with_public_ip + import_subnet_routes_with_public_ip = var.export_local_subnet_routes_with_public_ip + depends_on = [null_resource.module_depends_on, google_compute_network_peering.local_network_peering] } diff --git a/modules/network-peering/variables.tf b/modules/network-peering/variables.tf index 087d20cb..c4b7409d 100644 --- a/modules/network-peering/variables.tf +++ b/modules/network-peering/variables.tf @@ -42,6 +42,18 @@ variable "export_local_custom_routes" { default = false } +variable "export_peer_subnet_routes_with_public_ip" { + description = "Export custom routes to local network from peer network (defaults to false; causes the Local Peering Connection to align with the [provider default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_network_peering#import_subnet_routes_with_public_ip), and the Remote Peering Connection to be opposite the provider default)." + type = bool + default = false +} + +variable "export_local_subnet_routes_with_public_ip" { + description = "Export custom routes to peer network from local network (defaults to true; causes the Local Peering Connection to align with the [provider default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_network_peering#export_subnet_routes_with_public_ip), and the Remote Peering Connection to be opposite the provider default)." + type = bool + default = true +} + variable "module_depends_on" { description = "List of modules or resources this module depends on." type = list(any)