From b75b1f1138c2bb48ca6ac56e5bf64b0d727f0f5f Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Thu, 4 May 2023 20:59:08 -0700 Subject: [PATCH] set mimetypes on web files --- infra/main/website.tf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/infra/main/website.tf b/infra/main/website.tf index 2cce262..3f3c027 100644 --- a/infra/main/website.tf +++ b/infra/main/website.tf @@ -1,6 +1,19 @@ +locals { + content_types = { + css = "text/css" + html = "text/html" + js = "application/javascript" + json = "application/json" + txt = "text/plain" + png = "image/png" + svg = "image/svg+xml" + } +} + resource "digitalocean_spaces_bucket" "website" { name = "website-${random_id.suffix.hex}" region = var.region + acl = "public-read" } resource "digitalocean_spaces_bucket_object" "website" { @@ -10,7 +23,9 @@ resource "digitalocean_spaces_bucket_object" "website" { source = "${var.out_dir}/website/${each.value}" key = each.value etag = filemd5("${var.out_dir}/website/${each.value}") + content_type = lookup(local.content_types, element(split(".", each.value), length(split(".", each.value)) - 1), "text/plain") acl = "public-read" + content_encoding = "utf-8" } resource "tls_private_key" "website" {