resource "digitalocean_spaces_bucket" "website" { name = "website-${random_id.suffix.hex}" region = var.region } resource "digitalocean_spaces_bucket_object" "website" { for_each = fileset("${var.out_dir}/website", "*") region = var.region bucket = digitalocean_spaces_bucket.website.name source = "${var.out_dir}/website/${each.value}" key = each.value etag = filemd5("${var.out_dir}/website/${each.value}") acl = "public-read" } resource "tls_private_key" "website" { algorithm = "RSA" } resource "digitalocean_certificate" "website" { name = "le-terraform-example" type = "lets_encrypt" domains = [ digitalocean_domain.default.name, format("%s%s", "www.", digitalocean_domain.default.name) ] } resource "digitalocean_cdn" "website" { origin = digitalocean_spaces_bucket.website.bucket_domain_name certificate_name = digitalocean_certificate.website.name depends_on = [ digitalocean_spaces_bucket.website ] } # ## Handle record for CDN redirect # resource "digitalocean_record" "cdn" { # domain = digitalocean_domain.default.name # type = "CNAME" # name = digitalocean_cdn.distrust_co.origin # value = "${digitalocean_domain.default.name}." # depends_on = [ # digitalocean_cdn.distrust_co # ] # } # # Output the endpoint for the CDN resource # output "fqdn" { # value = digitalocean_cdn.distrust_co.endpoint # } # # # output "cdn_origin" { # value = digitalocean_cdn.distrust_co.origin # } # # Handle record for distrust.co # resource "digitalocean_record" "distrust_co-cdn" { # domain = digitalocean_domain.default.name # type = "A" # name = "@" # value = "143.198.235.76" # depends_on = [ # digitalocean_cdn.distrust_co # ] # }