-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
54 lines (46 loc) · 1.19 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
}
}
provider "cloudflare" {
api_token = var.cf_api_token
}
resource "cloudflare_record" "mx" {
for_each = {
primary = { server = "in1-smtp.messagingengine.com", priority = 10 }
secondary = { server = "in2-smtp.messagingengine.com", priority = 20 }
}
zone_id = var.cf_zone_id
name = var.sub_domain
type = "MX"
value = each.value.server
ttl = var.ttl
priority = each.value.priority
}
resource "cloudflare_record" "spf" {
zone_id = var.cf_zone_id
name = var.sub_domain
type = "TXT"
value = "v=spf1 include:spf.messagingengine.com ?all "
ttl = var.ttl
}
resource "cloudflare_record" "dkim" {
for_each = { for i in range(1, 4) : "${i}" => i }
zone_id = var.cf_zone_id
type = "CNAME"
name = "fm${each.value}._domainkey"
value = "fm${each.value}.${var.domain_name}.dkim.fmhosted.com"
ttl = var.ttl
}
resource "cloudflare_record" "dmarc" {
count = length(var.dmarc) > 0 ? 1 : 0
zone_id = var.cf_zone_id
name = "_dmarc"
type = "TXT"
value = var.dmarc
ttl = var.ttl
}