From 82b3bf509b44ea038179f7e200f16afbda9f5a29 Mon Sep 17 00:00:00 2001 From: Stephen Bancroft Date: Mon, 25 Mar 2024 14:57:17 +1100 Subject: [PATCH 1/3] Added feature and fix for vmw peering --- modules/gcve-network-peering/README.md | 29 +++++++++++------------ modules/gcve-network-peering/main.tf | 10 ++++++++ modules/gcve-network-peering/variables.tf | 6 +++++ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/modules/gcve-network-peering/README.md b/modules/gcve-network-peering/README.md index dadb963..2e04257 100644 --- a/modules/gcve-network-peering/README.md +++ b/modules/gcve-network-peering/README.md @@ -14,21 +14,20 @@ This module contains the terraform to setup and define network connectivity betw Basic usage of this module is as follows: ```hcl -module "example" { - source = "" +module "network-peering" { + source = "github.com/GoogleCloudPlatform/gcve-iac-foundations/modules/gcve-network-peering" # Required variables - gcve_peer_name = - nw_location = - nw_name = - peer_network_type = - peer_nw_name = - peer_nw_project_id = - project_id = + gcve_peer_name = + project_id = + vmware_engine_network_id = + peer_network_type = + peer_nw_name = + peer_nw_project_id = + # Optional variables - gcve_peer_description = "" - nw_project_id = "The relative resource project of the VMware Engine network" + gcve_peer_description = peer_export_custom_routes = true peer_export_custom_routes_with_public_ip = false peer_import_custom_routes = true @@ -52,9 +51,8 @@ module "example" { |------|-------------|------|---------|:--------:| | [gcve\_peer\_description](#input\_gcve\_peer\_description) | User-provided description for this network peering. | `string` | `""` | no | | [gcve\_peer\_name](#input\_gcve\_peer\_name) | The ID of the Network Peering. | `string` | n/a | yes | -| [nw\_location](#input\_nw\_location) | The relative resource location of the VMware Engine network | `string` | n/a | yes | -| [nw\_name](#input\_nw\_name) | The relative resource name of the VMware Engine network | `string` | n/a | yes | -| [nw\_project\_id](#input\_nw\_project\_id) | n/a | `string` | `"The relative resource project of the VMware Engine network"` | no | +| [vmware\_engine_network_id](#input\_vmware\_engine\_network\_id) | The VMware Engine network id | `string` | n/a | yes | +| [project\_id](#input\_nw\_project\_id) | The Project ID of the VMWARE Engine Project | `string` | n/a | yes | | [peer\_export\_custom\_routes](#input\_peer\_export\_custom\_routes) | True if custom routes are exported to the peered network; false otherwise. | `bool` | `true` | no | | [peer\_export\_custom\_routes\_with\_public\_ip](#input\_peer\_export\_custom\_routes\_with\_public\_ip) | True if all subnet routes with a public IP address range are exported; false otherwise | `bool` | `false` | no | | [peer\_import\_custom\_routes](#input\_peer\_import\_custom\_routes) | True if custom routes are imported from the peered network; false otherwise. | `bool` | `true` | no | @@ -63,7 +61,8 @@ module "example" { | [peer\_nw\_location](#input\_peer\_nw\_location) | The relative resource location of the network to peer with a standard VMware Engine network. The provided network can be a consumer VPC network or another standard VMware Engine network. | `string` | `"global"` | no | | [peer\_nw\_name](#input\_peer\_nw\_name) | The relative resource name of the network to peer with a standard VMware Engine network. The provided network can be a consumer VPC network or another standard VMware Engine network. | `string` | n/a | yes | | [peer\_nw\_project\_id](#input\_peer\_nw\_project\_id) | The relative resource project of the network to peer with a standard VMware Engine network. The provided network can be a consumer VPC network or another standard VMware Engine network. | `string` | n/a | yes | -| [project\_id](#input\_project\_id) | he ID of the project in which the resource belongs | `string` | n/a | yes | +| [create\_remote\_peer](#create\_remote\_peer) | To automatically create the respective peering in the remote project, set this to true. | `bool` | `false` | no | + ## Outputs diff --git a/modules/gcve-network-peering/main.tf b/modules/gcve-network-peering/main.tf index c33670a..ff8ca09 100644 --- a/modules/gcve-network-peering/main.tf +++ b/modules/gcve-network-peering/main.tf @@ -65,3 +65,13 @@ resource "google_vmwareengine_network_peering" "peering" { export_custom_routes_with_public_ip = var.peer_export_custom_routes_with_public_ip import_custom_routes_with_public_ip = var.peer_import_custom_routes_with_public_ip } + +resource "google_vmwareengine_network_peering" "vmw-engine-network-peering" { + count = var.create_remote_peer == true ? 1 : 0 + project = var.peer_nw_project_id + name = var.gcve_peer_name + description = var.gcve_peer_description + peer_network = local.peer_network + peer_network_type = "STANDARD" + vmware_engine_network = var.vmware_engine_network_id +} \ No newline at end of file diff --git a/modules/gcve-network-peering/variables.tf b/modules/gcve-network-peering/variables.tf index ec8b2e1..ae77da8 100644 --- a/modules/gcve-network-peering/variables.tf +++ b/modules/gcve-network-peering/variables.tf @@ -84,3 +84,9 @@ variable "peer_import_custom_routes_with_public_ip" { default = false description = "True if custom routes are imported from the peered network; false otherwise." } + +variable "create_remote_peer" { + type = bool + default = false + description = "True if you would like to create the remote peer in the peered-to project" +} From 06e83fe232f0788e7275206780001c11a39b65f5 Mon Sep 17 00:00:00 2001 From: Stephen Bancroft Date: Mon, 25 Mar 2024 15:08:08 +1100 Subject: [PATCH 2/3] Fix indent --- modules/gcve-network-peering/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gcve-network-peering/README.md b/modules/gcve-network-peering/README.md index 2e04257..9b93f0f 100644 --- a/modules/gcve-network-peering/README.md +++ b/modules/gcve-network-peering/README.md @@ -19,7 +19,7 @@ module "network-peering" { # Required variables gcve_peer_name = - project_id = + project_id = vmware_engine_network_id = peer_network_type = From 4f37b33e9bb0e3919e595f07d0fa6800ed99def0 Mon Sep 17 00:00:00 2001 From: Stephen Bancroft Date: Wed, 27 Mar 2024 10:34:11 +1100 Subject: [PATCH 3/3] Added optional args to google_vmwareengine_network_peering --- modules/gcve-network-peering/main.tf | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/gcve-network-peering/main.tf b/modules/gcve-network-peering/main.tf index ff8ca09..09125a3 100644 --- a/modules/gcve-network-peering/main.tf +++ b/modules/gcve-network-peering/main.tf @@ -67,11 +67,15 @@ resource "google_vmwareengine_network_peering" "peering" { } resource "google_vmwareengine_network_peering" "vmw-engine-network-peering" { - count = var.create_remote_peer == true ? 1 : 0 - project = var.peer_nw_project_id - name = var.gcve_peer_name - description = var.gcve_peer_description - peer_network = local.peer_network - peer_network_type = "STANDARD" - vmware_engine_network = var.vmware_engine_network_id + count = var.create_remote_peer == true ? 1 : 0 + name = var.gcve_peer_name + description = var.gcve_peer_description + project = var.peer_nw_project_id + vmware_engine_network = var.vmware_engine_network_id + peer_network = local.peer_network + peer_network_type = "STANDARD" + export_custom_routes = var.peer_export_custom_routes + import_custom_routes = var.peer_import_custom_routes + export_custom_routes_with_public_ip = var.peer_export_custom_routes_with_public_ip + import_custom_routes_with_public_ip = var.peer_import_custom_routes_with_public_ip } \ No newline at end of file