Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the export_public_ip_routes variable in the net-vpc-peering mod… #1374

Merged
merged 2 commits into from
May 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions modules/net-vpc-peering/README.md
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
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
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