From a94f56b22733294847cbe85dc399971ed9f16b8a Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Sat, 25 May 2024 14:11:27 -0600 Subject: [PATCH 01/17] Support `redis_version` --- README.md | 1 + redis.tf | 2 ++ variables.tf | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index f5c2ff1..96755b6 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ No modules. | [database\_password](#input\_database\_password) | The password to use for the database. You can find the password in your 'config/passwords.yaml' file. | `string` | n/a | yes | | [database\_tier](#input\_database\_tier) | The tier of the database to use. Defaults to 'db-f1-micro'. | `string` | `"db-f1-micro"` | no | | [database\_version](#input\_database\_version) | The version of the database to use. Defaults to 'POSTGRES\_14'. Note that only PostgreSQL is supported. | `string` | `"POSTGRES_14"` | no | +| [redis\_version](#input\_redis\_version) | The version of Redis to use. Defaults to 'REDIS_7_2'. | `string` | `"REDIS_7_2"` | no | | [dns\_managed\_zone](#input\_dns\_managed\_zone) | The name of the DNS managed zone to use for the Serverpod infrastructure. If this is not set, a new managed zone will be created. | `string` | `""` | no | | [enable\_redis](#input\_enable\_redis) | Whether to enable Redis. Defaults to false. | `bool` | `false` | no | | [enable\_ssh](#input\_enable\_ssh) | Whether to enable SSH access to instances in the autoscaling group. Defaults to true. | `bool` | `true` | no | diff --git a/redis.tf b/redis.tf index f954a7f..59b7302 100644 --- a/redis.tf +++ b/redis.tf @@ -7,5 +7,7 @@ resource "google_redis_instance" "serverpod" { tier = var.redis_tier memory_size_gb = var.redis_memory_size_gb + redis_version = var.redis_version + authorized_network = google_compute_network.serverpod.id } \ No newline at end of file diff --git a/variables.tf b/variables.tf index db701c7..6dac1d1 100644 --- a/variables.tf +++ b/variables.tf @@ -66,6 +66,12 @@ variable "database_version" { default = "POSTGRES_14" } +variable "redis_version" { + description = "The version of Redis to use. Defaults to 'REDIS_7_2'." + type = string + default = "REDIS_7_2" +} + variable "database_tier" { description = "The tier of the database to use. Defaults to 'db-f1-micro'." type = string From 1184d219a86c0d9826f924c03c685f55218a587d Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:14:54 -0600 Subject: [PATCH 02/17] Add var.authorized_networks --- database.tf | 1 + variables.tf | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/database.tf b/database.tf index d30ba34..ea39d81 100644 --- a/database.tf +++ b/database.tf @@ -17,6 +17,7 @@ resource "google_sql_database_instance" "serverpod" { ip_configuration { ipv4_enabled = true private_network = google_compute_network.serverpod.id + authorized_networks = var.authorized_networks } } diff --git a/variables.tf b/variables.tf index 1853c05..5dc642c 100644 --- a/variables.tf +++ b/variables.tf @@ -26,6 +26,12 @@ variable "top_domain" { type = string } +variable "authorized_networks" { + description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." + type = map + default = null +} + variable "autoscaling_min_size" { description = "The minimum number of instances to run in the autoscaling group. Defaults to 1." default = 1 From 4e20501f79cf96a74d4e0e4815d574ca6bf9a26b Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:17:50 -0600 Subject: [PATCH 03/17] Fix syntax issue --- database.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database.tf b/database.tf index ea39d81..8505e8d 100644 --- a/database.tf +++ b/database.tf @@ -17,7 +17,7 @@ resource "google_sql_database_instance" "serverpod" { ip_configuration { ipv4_enabled = true private_network = google_compute_network.serverpod.id - authorized_networks = var.authorized_networks + var.authorized_networks } } From 1797b3ec67294f625974f9cbf65956c6d844463a Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:20:51 -0600 Subject: [PATCH 04/17] More fixes --- database.tf | 5 ++++- variables.tf | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/database.tf b/database.tf index 8505e8d..dfda29a 100644 --- a/database.tf +++ b/database.tf @@ -17,7 +17,10 @@ resource "google_sql_database_instance" "serverpod" { ip_configuration { ipv4_enabled = true private_network = google_compute_network.serverpod.id - var.authorized_networks + authorized_networks { + name = authorized_networks_name + value = authorized_networks_ip_range + } } } diff --git a/variables.tf b/variables.tf index 5dc642c..8f95d39 100644 --- a/variables.tf +++ b/variables.tf @@ -26,9 +26,15 @@ variable "top_domain" { type = string } -variable "authorized_networks" { - description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = map +variable "authorized_networks_name" { + description = "The name of the network authorized to connect to the database from outside the Serverpod infrastructure." + type = string + default = null +} + +variable "authorized_networks_ip_range" { + description = "The IP address range of the network authorized to connect to the database from outside the Serverpod infrastructure, in CIDR notation." + type = string default = null } From 432a5b0bf13ba3eff729472fdff4b8cb8e6916aa Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:22:45 -0600 Subject: [PATCH 05/17] More fixes --- database.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database.tf b/database.tf index dfda29a..347f3f3 100644 --- a/database.tf +++ b/database.tf @@ -18,8 +18,8 @@ resource "google_sql_database_instance" "serverpod" { ipv4_enabled = true private_network = google_compute_network.serverpod.id authorized_networks { - name = authorized_networks_name - value = authorized_networks_ip_range + name = var.authorized_networks_name + value = var.authorized_networks_ip_range } } } From 9ea3993948f68257e9d272cb1280381c1f5c7c13 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:32:25 -0600 Subject: [PATCH 06/17] More fixes --- database.tf | 9 +++------ variables.tf | 15 ++++++--------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/database.tf b/database.tf index 347f3f3..5c9a5a3 100644 --- a/database.tf +++ b/database.tf @@ -15,12 +15,9 @@ resource "google_sql_database_instance" "serverpod" { } ip_configuration { - ipv4_enabled = true - private_network = google_compute_network.serverpod.id - authorized_networks { - name = var.authorized_networks_name - value = var.authorized_networks_ip_range - } + ipv4_enabled = true + private_network = google_compute_network.serverpod.id + authorized_networks = var.authorized_networks } } diff --git a/variables.tf b/variables.tf index 8f95d39..3f7d5b7 100644 --- a/variables.tf +++ b/variables.tf @@ -26,15 +26,12 @@ variable "top_domain" { type = string } -variable "authorized_networks_name" { - description = "The name of the network authorized to connect to the database from outside the Serverpod infrastructure." - type = string - default = null -} - -variable "authorized_networks_ip_range" { - description = "The IP address range of the network authorized to connect to the database from outside the Serverpod infrastructure, in CIDR notation." - type = string +variable "authorized_networks" { + description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." + type = map(object({ + name = string + value = string + })) default = null } From 045c0e08c1b97086fc43e8b95e51ea1c8b68ed58 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:38:56 -0600 Subject: [PATCH 07/17] More fixes --- variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variables.tf b/variables.tf index 3f7d5b7..6dbd6a6 100644 --- a/variables.tf +++ b/variables.tf @@ -28,10 +28,10 @@ variable "top_domain" { variable "authorized_networks" { description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = map(object({ + type = object({ name = string value = string - })) + }) default = null } From ebfe2f9320369a13866824d5761c8b320cea4ed8 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:40:02 -0600 Subject: [PATCH 08/17] More fixes --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 6dbd6a6..64df51c 100644 --- a/variables.tf +++ b/variables.tf @@ -28,7 +28,7 @@ variable "top_domain" { variable "authorized_networks" { description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = object({ + type = map({ name = string value = string }) From 4c05f006581a39140377bf9d9086e4298ab57c1e Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:41:21 -0600 Subject: [PATCH 09/17] More fixes --- variables.tf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/variables.tf b/variables.tf index 64df51c..e949133 100644 --- a/variables.tf +++ b/variables.tf @@ -28,10 +28,7 @@ variable "top_domain" { variable "authorized_networks" { description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = map({ - name = string - value = string - }) + type = map(string) default = null } From d9ca563fe3bc6a8f75c8e47cde3836557900f207 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:42:28 -0600 Subject: [PATCH 10/17] More fixes --- variables.tf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index e949133..3f7d5b7 100644 --- a/variables.tf +++ b/variables.tf @@ -28,7 +28,10 @@ variable "top_domain" { variable "authorized_networks" { description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = map(string) + type = map(object({ + name = string + value = string + })) default = null } From 51190cc8aea8eee1aa5d5d34ba8216e2123132d2 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:45:34 -0600 Subject: [PATCH 11/17] More fixes --- database.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/database.tf b/database.tf index 5c9a5a3..65ffe99 100644 --- a/database.tf +++ b/database.tf @@ -17,6 +17,14 @@ resource "google_sql_database_instance" "serverpod" { ip_configuration { ipv4_enabled = true private_network = google_compute_network.serverpod.id + + dynamic "authorized_networks" { + for_each = var.authorized_networks == null ? [] : [var.authorized_networks] + content { + name = var.authorized_networks.name + value = var.authorized_networks.value + } + } authorized_networks = var.authorized_networks } } From 9ae9190adfe80bbb35d2bbe19b900f1729929a91 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:49:37 -0600 Subject: [PATCH 12/17] More fixes --- variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variables.tf b/variables.tf index 3f7d5b7..6dbd6a6 100644 --- a/variables.tf +++ b/variables.tf @@ -28,10 +28,10 @@ variable "top_domain" { variable "authorized_networks" { description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = map(object({ + type = object({ name = string value = string - })) + }) default = null } From dde83b166d6e252068c5630964e3751926ece91a Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:50:40 -0600 Subject: [PATCH 13/17] More fixes --- database.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database.tf b/database.tf index 65ffe99..7b8d701 100644 --- a/database.tf +++ b/database.tf @@ -25,7 +25,7 @@ resource "google_sql_database_instance" "serverpod" { value = var.authorized_networks.value } } - authorized_networks = var.authorized_networks + authorized_networks = var.authorized_networks == null ? {} : var.authorized_networks } } From 5122babebd3663757230efff1466e2b92dd948b5 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 19:53:20 -0600 Subject: [PATCH 14/17] More fixes --- database.tf | 2 +- variables.tf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/database.tf b/database.tf index 7b8d701..65ffe99 100644 --- a/database.tf +++ b/database.tf @@ -25,7 +25,7 @@ resource "google_sql_database_instance" "serverpod" { value = var.authorized_networks.value } } - authorized_networks = var.authorized_networks == null ? {} : var.authorized_networks + authorized_networks = var.authorized_networks } } diff --git a/variables.tf b/variables.tf index 6dbd6a6..3f7d5b7 100644 --- a/variables.tf +++ b/variables.tf @@ -28,10 +28,10 @@ variable "top_domain" { variable "authorized_networks" { description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = object({ + type = map(object({ name = string value = string - }) + })) default = null } From 1175afac7f5ed3f59437369b27a508bc129377f0 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 20:03:34 -0600 Subject: [PATCH 15/17] More fixes --- variables.tf | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/variables.tf b/variables.tf index 3f7d5b7..9f01316 100644 --- a/variables.tf +++ b/variables.tf @@ -28,11 +28,10 @@ variable "top_domain" { variable "authorized_networks" { description = "The networks authorized to connect to the database from outside the Serverpod infrastructure." - type = map(object({ - name = string - value = string - })) - default = null + type = object({ + name = string + value = string + }) } variable "autoscaling_min_size" { From 3343d9794e19626efff12873e241acbb678112ff Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 20:04:33 -0600 Subject: [PATCH 16/17] More fixes --- database.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/database.tf b/database.tf index 65ffe99..f4ae841 100644 --- a/database.tf +++ b/database.tf @@ -25,7 +25,6 @@ resource "google_sql_database_instance" "serverpod" { value = var.authorized_networks.value } } - authorized_networks = var.authorized_networks } } From bc6072ce1597b782c3982b1de4ead38b3393264a Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Tue, 23 Jul 2024 20:06:31 -0600 Subject: [PATCH 17/17] More fixes --- variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/variables.tf b/variables.tf index 9f01316..a893089 100644 --- a/variables.tf +++ b/variables.tf @@ -32,6 +32,7 @@ variable "authorized_networks" { name = string value = string }) + default = null } variable "autoscaling_min_size" {