Skip to content

Commit 8666553

Browse files
feat: Add support for export_local_subnet_routes_with_public_ip and export_peer_subnet_routes_with_public_ip (#255)
1 parent adf9706 commit 8666553

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

modules/network-peering/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ module "peering-a-c" {
4949
| Name | Description | Type | Default | Required |
5050
|------|-------------|------|---------|:--------:|
5151
| export\_local\_custom\_routes | Export custom routes to peer network from local network. | `bool` | `false` | no |
52+
| 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 |
5253
| export\_peer\_custom\_routes | Export custom routes to local network from peer network. | `bool` | `false` | no |
54+
| 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 |
5355
| local\_network | Resource link of the network to add a peering to. | `string` | n/a | yes |
5456
| module\_depends\_on | List of modules or resources this module depends on. | `list(any)` | `[]` | no |
5557
| peer\_network | Resource link of the peer network. | `string` | n/a | yes |

modules/network-peering/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ resource "random_string" "network_peering_suffix" {
3030
special = false
3131
length = 4
3232
}
33+
3334
resource "google_compute_network_peering" "local_network_peering" {
3435
provider = google-beta
3536
name = local.local_network_peering_name
@@ -38,6 +39,9 @@ resource "google_compute_network_peering" "local_network_peering" {
3839
export_custom_routes = var.export_local_custom_routes
3940
import_custom_routes = var.export_peer_custom_routes
4041

42+
export_subnet_routes_with_public_ip = var.export_local_subnet_routes_with_public_ip
43+
import_subnet_routes_with_public_ip = var.export_peer_subnet_routes_with_public_ip
44+
4145
depends_on = [null_resource.module_depends_on]
4246
}
4347

@@ -49,6 +53,9 @@ resource "google_compute_network_peering" "peer_network_peering" {
4953
export_custom_routes = var.export_peer_custom_routes
5054
import_custom_routes = var.export_local_custom_routes
5155

56+
export_subnet_routes_with_public_ip = var.export_peer_subnet_routes_with_public_ip
57+
import_subnet_routes_with_public_ip = var.export_local_subnet_routes_with_public_ip
58+
5259
depends_on = [null_resource.module_depends_on, google_compute_network_peering.local_network_peering]
5360
}
5461

modules/network-peering/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ variable "export_local_custom_routes" {
4242
default = false
4343
}
4444

45+
variable "export_peer_subnet_routes_with_public_ip" {
46+
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)."
47+
type = bool
48+
default = false
49+
}
50+
51+
variable "export_local_subnet_routes_with_public_ip" {
52+
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)."
53+
type = bool
54+
default = true
55+
}
56+
4557
variable "module_depends_on" {
4658
description = "List of modules or resources this module depends on."
4759
type = list(any)

0 commit comments

Comments
 (0)