diff --git a/modules/net-vpc-peering/README.md b/modules/net-vpc-peering/README.md index 0555b994da..b9595c1df7 100644 --- a/modules/net-vpc-peering/README.md +++ b/modules/net-vpc-peering/README.md @@ -46,12 +46,13 @@ module "peering-a-c" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [local_network](variables.tf#L30) | Resource link of the network to add a peering to. | string | ✓ | | -| [peer_network](variables.tf#L41) | Resource link of the peer network. | string | ✓ | | +| [local_network](variables.tf#L36) | Resource link of the network to add a peering to. | string | ✓ | | +| [peer_network](variables.tf#L47) | Resource link of the peer network. | string | ✓ | | | [export_local_custom_routes](variables.tf#L18) | Export custom routes to peer network from local network. | bool | | false | | [export_peer_custom_routes](variables.tf#L24) | Export custom routes to local network from peer network. | bool | | false | -| [peer_create_peering](variables.tf#L35) | Create the peering on the remote side. If false, only the peering from this network to the remote network is created. | bool | | true | -| [prefix](variables.tf#L46) | Optional name prefix for the network peerings. | string | | null | +| [export_public_ip_routes](variables.tf#L30) | Export subnet routes with public ip. | bool | | true | +| [peer_create_peering](variables.tf#L41) | Create the peering on the remote side. If false, only the peering from this network to the remote network is created. | bool | | true | +| [prefix](variables.tf#L52) | Optional name prefix for the network peerings. | string | | null | ## Outputs diff --git a/modules/net-vpc-peering/main.tf b/modules/net-vpc-peering/main.tf index f705df715b..204b5015f5 100644 --- a/modules/net-vpc-peering/main.tf +++ b/modules/net-vpc-peering/main.tf @@ -21,20 +21,22 @@ locals { } resource "google_compute_network_peering" "local_network_peering" { - name = "${local.prefix}${local.local_network_name}-${local.peer_network_name}" - network = var.local_network - peer_network = var.peer_network - export_custom_routes = var.export_local_custom_routes - import_custom_routes = var.export_peer_custom_routes + name = "${local.prefix}${local.local_network_name}-${local.peer_network_name}" + network = var.local_network + peer_network = var.peer_network + export_custom_routes = var.export_local_custom_routes + import_custom_routes = var.export_peer_custom_routes + export_subnet_routes_with_public_ip = var.export_public_ip_routes } resource "google_compute_network_peering" "peer_network_peering" { - count = var.peer_create_peering ? 1 : 0 - name = "${local.prefix}${local.peer_network_name}-${local.local_network_name}" - network = var.peer_network - peer_network = var.local_network - export_custom_routes = var.export_peer_custom_routes - import_custom_routes = var.export_local_custom_routes + count = var.peer_create_peering ? 1 : 0 + name = "${local.prefix}${local.peer_network_name}-${local.local_network_name}" + network = var.peer_network + peer_network = var.local_network + export_custom_routes = var.export_peer_custom_routes + import_custom_routes = var.export_local_custom_routes + export_subnet_routes_with_public_ip = var.export_public_ip_routes depends_on = [google_compute_network_peering.local_network_peering] } diff --git a/modules/net-vpc-peering/variables.tf b/modules/net-vpc-peering/variables.tf index 8f5f15f676..408d1bc249 100644 --- a/modules/net-vpc-peering/variables.tf +++ b/modules/net-vpc-peering/variables.tf @@ -27,6 +27,12 @@ variable "export_peer_custom_routes" { default = false } +variable "export_public_ip_routes" { + description = "Export subnet routes with public ip." + type = bool + default = true +} + variable "local_network" { description = "Resource link of the network to add a peering to." type = string