Skip to content

Commit

Permalink
added the export_public_ip_routes variable in the net-vpc-peering mod… (
Browse files Browse the repository at this point in the history
#1374)

* added the export_public_ip_routes variable in the net-vpc-peering module to control the google_compute_network_peering resource created

* adding period to the variable description
  • Loading branch information
itManuel authored May 14, 2023
1 parent 60d579b commit dd1e5dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
9 changes: 5 additions & 4 deletions modules/net-vpc-peering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | <code>string</code> || |
| [peer_network](variables.tf#L41) | Resource link of the peer network. | <code>string</code> || |
| [local_network](variables.tf#L36) | Resource link of the network to add a peering to. | <code>string</code> || |
| [peer_network](variables.tf#L47) | Resource link of the peer network. | <code>string</code> || |
| [export_local_custom_routes](variables.tf#L18) | Export custom routes to peer network from local network. | <code>bool</code> | | <code>false</code> |
| [export_peer_custom_routes](variables.tf#L24) | Export custom routes to local network from peer network. | <code>bool</code> | | <code>false</code> |
| [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. | <code>bool</code> | | <code>true</code> |
| [prefix](variables.tf#L46) | Optional name prefix for the network peerings. | <code>string</code> | | <code>null</code> |
| [export_public_ip_routes](variables.tf#L30) | Export subnet routes with public ip. | <code>bool</code> | | <code>true</code> |
| [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. | <code>bool</code> | | <code>true</code> |
| [prefix](variables.tf#L52) | Optional name prefix for the network peerings. | <code>string</code> | | <code>null</code> |

## Outputs

Expand Down
24 changes: 13 additions & 11 deletions modules/net-vpc-peering/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
6 changes: 6 additions & 0 deletions modules/net-vpc-peering/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd1e5dc

Please sign in to comment.