From 1a593322441e713ff937cb905aea7aab1d951161 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Fri, 13 Jan 2023 17:16:35 -0800 Subject: add mailgun domain config --- clarkzjw.cc/infra/cloudflare.tf | 43 ++++++++++++++++++++++++++++++ clarkzjw.cc/infra/terraform.tfvars.example | 1 + clarkzjw.cc/infra/variables.tf | 5 ++++ 3 files changed, 49 insertions(+) create mode 100644 clarkzjw.cc/infra/terraform.tfvars.example (limited to 'clarkzjw.cc/infra') diff --git a/clarkzjw.cc/infra/cloudflare.tf b/clarkzjw.cc/infra/cloudflare.tf index f269129..61d9868 100644 --- a/clarkzjw.cc/infra/cloudflare.tf +++ b/clarkzjw.cc/infra/cloudflare.tf @@ -4,6 +4,7 @@ data "cloudflare_zones" "homelab_main_domain" { } } +# www variable "homelab_www_domain" { default = "clarkzjw.cc" } @@ -21,3 +22,45 @@ resource "cloudflare_record" "main" { ttl = 1 proxied = true } + +# notify +resource "cloudflare_record" "notify_SPF" { + zone_id = data.cloudflare_zones.homelab_main_domain.zones[0].id + # type = "SPF" causes DNS Validation Error (1004) + # https://github.com/cloudflare/terraform-provider-cloudflare/issues/1473 + type = "TXT" + name = "notify.${var.homelab_main_domain}" + value = "v=spf1 include:mailgun.org ~all" + + ttl = 1 +} + +resource "cloudflare_record" "notify_DKIM" { + name = "pic._domainkey.notify.${var.homelab_main_domain}" + type = "TXT" + zone_id = data.cloudflare_zones.homelab_main_domain.zones[0].id + value = var.homelab_notify_DKIM +} + +resource "cloudflare_record" "notify_CNAME" { + name = "email.notify.${var.homelab_main_domain}" + type = "CNAME" + zone_id = data.cloudflare_zones.homelab_main_domain.zones[0].id + value = "mailgun.org" +} + +resource "cloudflare_record" "notify_MX_a" { + name = "notify.${var.homelab_main_domain}" + type = "MX" + zone_id = data.cloudflare_zones.homelab_main_domain.zones[0].id + value = "mxa.mailgun.org" + priority = 10 +} + +resource "cloudflare_record" "notify_MX_b" { + name = "notify.${var.homelab_main_domain}" + type = "MX" + zone_id = data.cloudflare_zones.homelab_main_domain.zones[0].id + value = "mxb.mailgun.org" + priority = 10 +} diff --git a/clarkzjw.cc/infra/terraform.tfvars.example b/clarkzjw.cc/infra/terraform.tfvars.example new file mode 100644 index 0000000..6fd3085 --- /dev/null +++ b/clarkzjw.cc/infra/terraform.tfvars.example @@ -0,0 +1 @@ +homelab_notify_DKIM = "k=rsa; p=xxx" diff --git a/clarkzjw.cc/infra/variables.tf b/clarkzjw.cc/infra/variables.tf index faa527e..22f201a 100644 --- a/clarkzjw.cc/infra/variables.tf +++ b/clarkzjw.cc/infra/variables.tf @@ -2,3 +2,8 @@ variable "homelab_main_domain" { description = "HomeLab Main Domain" default = "clarkzjw.cc" } + +variable "homelab_notify_DKIM" { + description = "DKIM domain value from Mailgun" + default = "k=rsa; p=xxxx" +} \ No newline at end of file -- cgit v1.2.3