Terraform and MX Record for AWS SES - DNS Validation Error 1004

What is the name of the domain?

example.com

What is the error number?

1004

What is the error message?

Error: failed to create DNS record: DNS Validation Error (1004)

What is the issue you’re encountering

MX record doesn’t get created from terraform.

What steps have you taken to resolve the issue?

Searched on the cloudflare forums to find many dead end threads that have been closed so I can’t post there but must create a new one.
Added optional parameters to the resource blocks which were the accepted solutions in the other threads, such as topic id 599327
Manually added the record to test if that would get validated

What feature, service or problem is this related to?

Mail records

Here is the terraform code that I used. Similar posts suggested adding the optional priority value to the block, which did not solve the error.

resource "cloudflare_record" "zone_dns_records_mx1" {
  count             = var.my_bool == true ? 1 : 0
  zone_id 	= "<my zone id>"
  type    	        = "MX"
  name       	= "<my-domain>"
  value   	        = "10 feedback-smtp.<aws-region>.amazonses.com"
  proxied 	        = false
  ttl                   = "600"
  priority           = 20
}

I am coming from route53 in AWS and migrating records over to cloudflare.
In route53, the records property of a aws_route53_record resource block in terraform is 10 feedback-smtp.amazonses.com
In cloudflare, the 10 is set as the priority value, and the record value (the value property in the cloudflare_record resource) is the remaining feedback-smtp.amazonses.com

After looking thru github for similar cloudflare_records for SES, I found some examples that separate the value and the priority, such as this one

After modifying my code block to have the value and priority separated instead of in the same string as they were in route53, the record created.

resource “cloudflare_record” “zone_dns_records_mx1” {
count = var.my_bool == true ? 1 : 0
zone_id = “”
type = “MX
name = “”
priority = 10
value = “feedback-smtp..amazonses.com”
proxied = false
ttl = “600”
}

Priority is its own field. You included a priority with the value as well.

resource "cloudflare_record" "domain_mx_1" {
  name     = "example.com"
  priority = 20
  proxied  = false
  ttl      = 1
  type     = "MX"
  value    = "mx1.example.com"
  zone_id  = "ZONE_ID"
}
1 Like