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" {