From 55df7fa5c270d5ef075965710e690db417d56f40 Mon Sep 17 00:00:00 2001 From: shane Date: Mon, 30 Jan 2023 19:19:08 -0600 Subject: [PATCH] Add working base record set - Mail - Spaces Bucket - CDN - Nameserver --- backend/main.tf | 91 +++++++++++++++++++++++++-------------------- backend/provider.tf | 6 +-- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/backend/main.tf b/backend/main.tf index 1afe857..21bd350 100644 --- a/backend/main.tf +++ b/backend/main.tf @@ -34,50 +34,59 @@ resource "digitalocean_spaces_bucket" "distrust_co" { acl = "public-read" } -## Handle record for CDN redirect -resource "digitalocean_record" "cdn" { - domain = "distrust.co" - type = "CNAME" - name = "${digitalocean_cdn.distrust_co.origin}." - value = "distrust.co" -} - -## Create a DigitalOcean managed Let's Encrypt Certificate -resource "digitalocean_certificate" "cert" { - name = "cdn-cert" - type = "lets_encrypt" - domains = ["static.distrust.co"] -} - # Add a CDN endpoint to the Spaces Bucket resource "digitalocean_cdn" "distrust_co" { - origin = digitalocean_spaces_bucket.distrust_co.bucket_domain_name - certificate_name = digitalocean_certificate.cert.name - custom_domain = "static.distrust.co" + origin = digitalocean_spaces_bucket.distrust_co.bucket_domain_name + # certificate_name = digitalocean_certificate.cert.name + # custom_domain = "static.distrust.co" + depends_on = [ + digitalocean_spaces_bucket.distrust_co + ] } +## 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 + ] +} + +# ## Create a DigitalOcean managed Let's Encrypt Certificate +# resource "digitalocean_certificate" "cert" { +# name = "cdn-cert" +# type = "lets_encrypt" +# domains = ["static.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" { - domain = "distrust.co" - type = "CNAME" - name = "@" - value = digitalocean_cdn.distrust_co.origin -} +# # Handle record for distrust.co +# resource "digitalocean_record" "distrust_co-cdn" { +# domain = digitalocean_domain.default.name +# type = "CNAME" +# name = "@" +# value = "${digitalocean_cdn.distrust_co.origin}." +# depends_on = [ +# digitalocean_cdn.distrust_co +# ] +# } resource "digitalocean_record" "CNAME-www" { domain = digitalocean_domain.default.name - type = "CNAME" - name = "www" - value = "@" + type = "CNAME" + name = "www-main" + value = "@" } # NameCheap Records @@ -200,39 +209,39 @@ resource "digitalocean_record" "mail-discovery" { resource "digitalocean_record" "mail-src-autodiscover" { domain = digitalocean_domain.default.id type = "SRV" - name = "_autodiscover" - port = 443 + name = "_autodiscover._tcp" + port = 443 priority = 0 - weight = 1 + weight = 1 value = "smtp.migadu.com" } resource "digitalocean_record" "mail-srv-submissions" { domain = digitalocean_domain.default.id type = "SRV" - name = "_submissions" - port = 465 + name = "_submissions._tcp" + port = 465 priority = 0 - weight = 1 + weight = 1 value = "smtp.migadu.com" } resource "digitalocean_record" "mail-srv-imaps" { domain = digitalocean_domain.default.id type = "SRV" - name = "_imaps" - port = 993 + name = "_imaps._tcp" + port = 993 priority = 0 - weight = 1 + weight = 1 value = "imap.migadu.com" } resource "digitalocean_record" "mail-srv-pop3s" { domain = digitalocean_domain.default.id type = "SRV" - name = "_pop3s" - port = 995 + name = "_pop3s._tcp" + port = 995 priority = 0 - weight = 1 + weight = 1 value = "pop.migadu.com" } diff --git a/backend/provider.tf b/backend/provider.tf index 9559867..0a0241e 100644 --- a/backend/provider.tf +++ b/backend/provider.tf @@ -9,7 +9,7 @@ terraform { version = "~> 2.0" } namecheap = { - source = "namecheap/namecheap" + source = "namecheap/namecheap" version = ">= 2.0.0" } } @@ -27,8 +27,8 @@ provider "acme" { provider "namecheap" { user_name = var.namecheap_user - api_user = var.namecheap_api_user - api_key = var.namecheap_api_key + api_user = var.namecheap_api_user + api_key = var.namecheap_api_key } variable "do_token" {}