From 3843089bd16210411ddba5a6e9d23af21ffbcc9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wawrzyniec=20=27Wawrzek=27=20Niewodnicza=C5=84ski?= Date: Tue, 15 Oct 2024 13:06:22 +0100 Subject: [PATCH] Adjust networking for DB --- postgres/README.md | 1 + postgres/main.tf | 7 ++----- postgres/variables.tf | 5 +++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/postgres/README.md b/postgres/README.md index 19999f3..953d7a2 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -39,6 +39,7 @@ No modules. | [db-version](#input\_db-version) | DB type and version (e.g. POSTGRES\_14) | `string` | `"POSTGRES_14"` | no | | [deletion-protection](#input\_deletion-protection) | Delete protection of DB | `bool` | `true` | no | | [name](#input\_name) | Name of the DB | `string` | n/a | yes | +| [network-id](#input\_network-id) | ID of the network | `string` | n/a | yes | | [network-name](#input\_network-name) | Name for the network | `string` | n/a | yes | | [private-network](#input\_private-network) | Switch to connect to a private network | `bool` | `true` | no | | [project](#input\_project) | Name of the GCP project | `string` | `"ivynet-tests"` | no | diff --git a/postgres/main.tf b/postgres/main.tf index f07f0c8..c0b1024 100644 --- a/postgres/main.tf +++ b/postgres/main.tf @@ -16,11 +16,8 @@ resource "google_sql_database_instance" "this" { dynamic "ip_configuration" { for_each = var.private-network ? [1] : [] content { - ipv4_enabled = false - psc_config { - psc_enabled = true - allowed_consumer_projects = [var.project] - } + ipv4_enabled = false + private_network = var.network-id } } } diff --git a/postgres/variables.tf b/postgres/variables.tf index 93dbb3a..79cb015 100644 --- a/postgres/variables.tf +++ b/postgres/variables.tf @@ -20,6 +20,11 @@ variable "name" { type = string } +variable "network-id" { + description = "ID of the network" + type = string +} + variable "network-name" { description = "Name for the network" type = string