Skip to content

Commit

Permalink
feat: Add support for export_local_subnet_routes_with_public_ip and e…
Browse files Browse the repository at this point in the history
…xport_peer_subnet_routes_with_public_ip (#255)
  • Loading branch information
rglenn-accenture committed Mar 4, 2021
1 parent adf9706 commit 8666553
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/network-peering/README.md
Expand Up @@ -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 |
Expand Down
7 changes: 7 additions & 0 deletions modules/network-peering/main.tf
Expand Up @@ -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
Expand All @@ -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]
}

Expand All @@ -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]
}

Expand Down
12 changes: 12 additions & 0 deletions modules/network-peering/variables.tf
Expand Up @@ -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)
Expand Down

0 comments on commit 8666553

Please sign in to comment.