From a94f56b22733294847cbe85dc399971ed9f16b8a Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Sat, 25 May 2024 14:11:27 -0600 Subject: [PATCH 1/5] 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 8f1e323d01f7cf05184f5f9ee7a57188bccabc2c Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Thu, 25 Jul 2024 22:36:54 -0600 Subject: [PATCH 2/5] Honor Cache-Control header for web backend --- load_balancer.tf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/load_balancer.tf b/load_balancer.tf index dd5248f..a44ef8d 100644 --- a/load_balancer.tf +++ b/load_balancer.tf @@ -151,6 +151,15 @@ resource "google_compute_backend_service" "web" { name = "serverpod-${var.runmode}-backend-web" protocol = "HTTP" enable_cdn = true + cdn_policy { + cache_mode = "USE_ORIGIN_HEADERS" + cache_key_policy { + include_host = true + include_protocol = true + include_query_string = true + include_http_headers = ["Cache-Control"] + } + } backend { group = google_compute_instance_group_manager.serverpod.instance_group From 08f03c802bd56a69dc2b54932a579f9e745a474c Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Thu, 25 Jul 2024 22:42:12 -0600 Subject: [PATCH 3/5] Tweaks to fix Terraform error --- load_balancer.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/load_balancer.tf b/load_balancer.tf index a44ef8d..eaf0deb 100644 --- a/load_balancer.tf +++ b/load_balancer.tf @@ -158,6 +158,8 @@ resource "google_compute_backend_service" "web" { include_protocol = true include_query_string = true include_http_headers = ["Cache-Control"] + signed_url_cache_max_age_sec = 0 + default_ttl = null } } From e92c132155a18e637d8564413ba1920a311be529 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Thu, 25 Jul 2024 22:43:49 -0600 Subject: [PATCH 4/5] Tweaks to fix Terraform error --- load_balancer.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/load_balancer.tf b/load_balancer.tf index eaf0deb..501b65e 100644 --- a/load_balancer.tf +++ b/load_balancer.tf @@ -158,9 +158,9 @@ resource "google_compute_backend_service" "web" { include_protocol = true include_query_string = true include_http_headers = ["Cache-Control"] - signed_url_cache_max_age_sec = 0 - default_ttl = null } + signed_url_cache_max_age_sec = 0 + default_ttl = null } backend { From be04a106ba2911c87fdff82b1c97efea2b6bf311 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Thu, 25 Jul 2024 22:52:36 -0600 Subject: [PATCH 5/5] Revert tweaks --- load_balancer.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/load_balancer.tf b/load_balancer.tf index 501b65e..a44ef8d 100644 --- a/load_balancer.tf +++ b/load_balancer.tf @@ -159,8 +159,6 @@ resource "google_compute_backend_service" "web" { include_query_string = true include_http_headers = ["Cache-Control"] } - signed_url_cache_max_age_sec = 0 - default_ttl = null } backend {