set mimetypes on web files

This commit is contained in:
Lance Vick 2023-05-04 20:59:08 -07:00
parent dc8c74238e
commit b75b1f1138
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 15 additions and 0 deletions

View File

@ -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" { resource "digitalocean_spaces_bucket" "website" {
name = "website-${random_id.suffix.hex}" name = "website-${random_id.suffix.hex}"
region = var.region region = var.region
acl = "public-read"
} }
resource "digitalocean_spaces_bucket_object" "website" { resource "digitalocean_spaces_bucket_object" "website" {
@ -10,7 +23,9 @@ resource "digitalocean_spaces_bucket_object" "website" {
source = "${var.out_dir}/website/${each.value}" source = "${var.out_dir}/website/${each.value}"
key = each.value key = each.value
etag = filemd5("${var.out_dir}/website/${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" acl = "public-read"
content_encoding = "utf-8"
} }
resource "tls_private_key" "website" { resource "tls_private_key" "website" {