1
0
Fork 0

Add working base record set

- Mail
- Spaces Bucket
- CDN
- Nameserver
This commit is contained in:
Shane Engelman 2023-01-30 19:19:08 -06:00
parent 66bf6fbaaa
commit 55df7fa5c2
Signed by: shane
GPG Key ID: D9DF703B83B9A9B5
2 changed files with 53 additions and 44 deletions

View File

@ -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"
}

View File

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