From 7a7eaf6eeff836ab43930281ff568313be5dc803 Mon Sep 17 00:00:00 2001 From: sanadhis Date: Sat, 17 Feb 2024 13:38:43 +0100 Subject: [PATCH] feat: allow to specify project_region for private-service-connect --- modules/private-service-connect/README.md | 19 ++++++++++--------- modules/private-service-connect/main.tf | 3 +++ modules/private-service-connect/variables.tf | 6 ++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/modules/private-service-connect/README.md b/modules/private-service-connect/README.md index b64f60d9..d579026a 100644 --- a/modules/private-service-connect/README.md +++ b/modules/private-service-connect/README.md @@ -48,15 +48,16 @@ If you have a firewall rule blocking egress traffic, you will need to configure ## Inputs -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| dns\_code | Code to identify DNS resources in the form of `{dns_code}-{dns_type}` | `string` | `"dz"` | no | -| forwarding\_rule\_name | Forwarding rule resource name. The forwarding rule name for PSC Google APIs must be an 1-20 characters string with lowercase letters and numbers and must start with a letter. Defaults to `globalrule` | `string` | `"globalrule"` | no | -| forwarding\_rule\_target | Target resource to receive the matched traffic. Only `all-apis` and `vpc-sc` are valid. | `string` | n/a | yes | -| network\_self\_link | Network self link for Private Service Connect. | `string` | n/a | yes | -| private\_service\_connect\_ip | The internal IP to be used for the private service connect. | `string` | n/a | yes | -| private\_service\_connect\_name | Private Service Connect endpoint name. Defaults to `global-psconnect-ip` | `string` | `"global-psconnect-ip"` | no | -| project\_id | Project ID for Private Service Connect. | `string` | n/a | yes | +| Name | Description | Type | Default | Required | +|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-------------------------|:--------:| +| dns\_code | Code to identify DNS resources in the form of `{dns_code}-{dns_type}` | `string` | `"dz"` | no | +| forwarding\_rule\_name | Forwarding rule resource name. The forwarding rule name for PSC Google APIs must be an 1-20 characters string with lowercase letters and numbers and must start with a letter. Defaults to `globalrule` | `string` | `"globalrule"` | no | +| forwarding\_rule\_target | Target resource to receive the matched traffic. Only `all-apis` and `vpc-sc` are valid. | `string` | n/a | yes | +| network\_self\_link | Network self link for Private Service Connect. | `string` | n/a | yes | +| private\_service\_connect\_ip | The internal IP to be used for the private service connect. | `string` | n/a | yes | +| private\_service\_connect\_name | Private Service Connect endpoint name. Defaults to `global-psconnect-ip` | `string` | `"global-psconnect-ip"` | no | +| project\_id | Project ID for Private Service Connect. | `string` | n/a | yes | +| project\_region | Project Region for Private Service Connect. | `string` | "us-central1" | yes | ## Outputs diff --git a/modules/private-service-connect/main.tf b/modules/private-service-connect/main.tf index 53bd647e..fb2b4aba 100644 --- a/modules/private-service-connect/main.tf +++ b/modules/private-service-connect/main.tf @@ -38,4 +38,7 @@ resource "google_compute_global_forwarding_rule" "forwarding_rule_private_servic network = var.network_self_link ip_address = google_compute_global_address.private_service_connect.id load_balancing_scheme = "" + service_directory_registrations { + service_directory_region = var.project_region + } } diff --git a/modules/private-service-connect/variables.tf b/modules/private-service-connect/variables.tf index f0045575..355c2cd2 100644 --- a/modules/private-service-connect/variables.tf +++ b/modules/private-service-connect/variables.tf @@ -19,6 +19,12 @@ variable "project_id" { type = string } +variable "project_region" { + description = "Project Region for Private Service Connect." + type = string + default = "us-central1" +} + variable "network_self_link" { description = "Network self link for Private Service Connect." type = string