Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mailgun setup #7

Merged
merged 1 commit into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions terraform/dependencies/mailgun/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
data "google_dns_managed_zone" "main" {
name = var.dns_zone
}

resource "google_dns_record_set" "mailgun_mx" {
name = data.google_dns_managed_zone.main.dns_name
type = "MX"
ttl = 300

managed_zone = data.google_dns_managed_zone.main.name

rrdatas = [
"10 mxa.mailgun.org",
"10 mxb.mailgun.org"
]
}

resource "google_dns_record_set" "mailgun_verification" {
name = data.google_dns_managed_zone.main.dns_name
type = "TXT"
ttl = 300

managed_zone = data.google_dns_managed_zone.main.name

rrdatas = [
"v=spf1 include:mailgun.org ~all"
]
}

resource "google_dns_record_set" "mailgun_verification_domainkey" {
name = "krs._domainkey.${data.google_dns_managed_zone.main.dns_name}"
type = "TXT"
ttl = 300

managed_zone = data.google_dns_managed_zone.main.name

rrdatas = [
var.verification
]
}

resource "google_dns_record_set" "mailgun_tracking" {
name = "email.${data.google_dns_managed_zone.main.dns_name}"
type = "CNAME"
ttl = 300

managed_zone = data.google_dns_managed_zone.main.name

rrdatas = [
"mailgun.org"
]
}
9 changes: 9 additions & 0 deletions terraform/dependencies/mailgun/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "dns_zone" {
description = "Name of the DNS zone"
type = string
}

variable "verification" {
description = "Verification domainkey value provided from Mailgun settings"
type = string
}
7 changes: 7 additions & 0 deletions terraform/environments/production/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ module "dutyfree_address" {
dns_zone = var.dns_zone
subdomain = "resource-types"
}

module "mailgun_records" {
source = "../../dependencies/mailgun"

dns_zone = var.dns_zone
verification = "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCiXNfw2u/anSOEvASvp94Rt+sp4ujO/AETVVtnqT3MC3By1EZBD8b0JowMZZKGkT9RwstC55fM66hhuJ0Az0lUZql2hex96k3mZjNUghaMoiPbIxa7bjYI2+vVEGIq5Y95PUJnKZMqEhe4WTob+vWGBsmKxHTr0lueShiO9fXFfwIDAQAB"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming this is meant to be public

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - it's being set in a public DNS record for Mailgun to verify control of the domain, so it'll be public whether it's committed or not. We had the same question. :P

}