From 8511101c65a498bcff31296ca0c5e5b4aebdc72a Mon Sep 17 00:00:00 2001 From: martintomas Date: Wed, 5 Jun 2024 14:21:50 +0200 Subject: [PATCH] feat: Turning on CDN for space/bucket with map data --- infrastructure/base/main.tf | 3 +++ infrastructure/base/modules/env/main.tf | 4 ++++ infrastructure/base/modules/space/outputs.tf | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/infrastructure/base/main.tf b/infrastructure/base/main.tf index 21d8ce5..f018410 100644 --- a/infrastructure/base/main.tf +++ b/infrastructure/base/main.tf @@ -62,6 +62,9 @@ locals { BUCKET_BUCKET = "${var.project_name}-staging-cms" BUCKET_ENDPOINT = "https://${var.do_region}.digitaloceanspaces.com" + # DigitalOcean Spaces to store map data + BUCKET_MAP_DATA_ENDPOINT = "https://${var.project_name}-staging.${var.do_region}.cdn.digitaloceanspaces.com" + # Database DATABASE_CLIENT = "postgres" DATABASE_HOST = module.staging.postgresql_host diff --git a/infrastructure/base/modules/env/main.tf b/infrastructure/base/modules/env/main.tf index 349574e..445c327 100644 --- a/infrastructure/base/modules/env/main.tf +++ b/infrastructure/base/modules/env/main.tf @@ -47,6 +47,10 @@ module "app" { do_app_image_tag = var.do_app_image_tag } +resource "digitalocean_cdn" "space_cdn" { + origin = module.space.bucket_domain_name +} + resource "digitalocean_spaces_bucket_cors_configuration" "space_cms_cors" { bucket = module.space_cms.space_id region = var.do_region diff --git a/infrastructure/base/modules/space/outputs.tf b/infrastructure/base/modules/space/outputs.tf index 1c4d13f..c0c89c7 100644 --- a/infrastructure/base/modules/space/outputs.tf +++ b/infrastructure/base/modules/space/outputs.tf @@ -1,3 +1,7 @@ output "space_id" { value = digitalocean_spaces_bucket.project_space.id } + +output "bucket_domain_name" { + value = digitalocean_spaces_bucket.project_space.bucket_domain_name +}