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

Addresses Issue #248 (Add Support for Exporting PUPIs - Network Peering Module) #255

Merged
merged 4 commits into from Mar 4, 2021
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
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