Skip to content

Setup MX configuration on a zone in Cloudflare

License

Notifications You must be signed in to change notification settings

tcarrondo/terraform-cloudflare-mx

Repository files navigation

cloudflare-mx

A Terraform module to configure mail configuration of a domain on a Cloudflare DNS zone the simpleway. It supports the current mail providers:

  • Google;
  • OVH;
  • Cloudflare;
  • Mailcow (Not a provider, but I need it).

Usage

provider "cloudflare" {
  email   = ""
  api_key = ""
  version = "~> 4"
}

module "mx_domain_com" {
  source  = "tcarrondo/mx/cloudflare"
  version = "~> 1"

  domain         = "domain.com"
  email_provider = "google"
}

Requirements

Name Version
terraform ~> 1
cloudflare ~> 4

Providers

Name Version
cloudflare ~> 4

Modules

No modules.

Resources

Name Type
cloudflare_email_routing_rule.this resource
cloudflare_email_routing_settings.this resource
cloudflare_record._dmarc resource
cloudflare_record.mx resource
cloudflare_record.mx_cf resource
cloudflare_record.spf resource
cloudflare_zone.domain data source

Inputs

Name Description Type Default Required
cloudflare_email_routings n/a
map(object({
custom_address = string
destination = string
}))
{} no
dmarc DMARC record string "v=DMARC1; p=none; pct=100; rua=mailto:; ruf=mailto:; sp=none; aspf=r" no
domain Zone domain name string n/a yes
dont_create_dmarc Don't we need DMARC record bool false no
dont_create_spf Don't we need SPF record bool false no
email_provider E-mail service provider string n/a yes
spf Custom SPF record string "" no

Outputs

No outputs.