namecheap / terraform-provider-namecheap

Terraform provider for Namecheap
Apache License 2.0
147 stars 30 forks source link

Unable to create MX records #37

Closed leveled closed 3 years ago

leveled commented 3 years ago

I seem to be unable to create MX records. Below is a redacted, abbreviated version of my terraform files. I've tried both with appended '.' and no '.' and it does not seem to make a difference. Some of these variables are not relevant to MX records, would omitting them help? I'd like to use the same generic module for record creation but can make a separate one if that is required.

terraform {
[...]

#Add MX Record
module "namecheap_MX_record" {
  source = "./tf_modules/namecheap/create-record"
  type = "MX"
  name = "mail.${var.domain}."
  domain = var.domain
  address = "mail.${var.domain}."
  mx_pref = "10"
  ttl = "3600"

[...]

#Specifies namecheap credentials
provider "namecheap" {
  username = var.namecheap_username
  api_user = var.namecheap_api_user
  token = var.namecheap_api_token
  ip = var.namecheap_ip_address
}

#Create record
resource "namecheap_record" "record" {
  name = var.name
  domain = var.domain
  type = var.type
  address = var.address
  mx_pref = var.mx_pref
  ttl = var.ttl
}

}
ifree92 commented 3 years ago

Thanks for reporting. The issue has been completely resolved in the new v2 major release.

Please have a look https://registry.terraform.io/providers/namecheap/namecheap/latest/docs/guides/namecheap_domain_records_guide#email-type to get details about MX records.