terraform-provider-namecheap icon indicating copy to clipboard operation
terraform-provider-namecheap copied to clipboard

FreeDNS subdomain records are all incorrectly going to the root domain

Open tranvansang opened this issue 1 year ago • 1 comments

Terraform Version

Terraform v1.3.3
on linux_amd64

Namecheap provider version

+ provider registry.terraform.io/namecheap/namecheap v2.1.0

Affected Resource(s)

  • namecheap_domain_records

Terraform Configuration Files

resource "namecheap_domain_records" "sub" {
	domain     = "sub.example.com"
	email_type = "MX"
	mode       = "MERGE"

	record {
		hostname = "@"
		type     = "A"
		address  = "1.2.3.4"
	}

	record {
		hostname = "mail"
		type     = "MX"
		address  = "mx.sub.example.com."
		mx_pref  = 10
	}

	record {
		hostname = "mx"
		type     = "A"
		address  = "1.2.3.4"
	}
}

resource "namecheap_domain_records" "main" {
	domain     = "example.com"
	mode       = "MERGE"
	email_type = "FWD"
	record {
		hostname = "sub"
		type     = "NS"
		address  = "freedns1.registrar-servers.com."
	}
	record {
		hostname = "sub"
		type     = "NS"
		address  = "freedns2.registrar-servers.com."
	}
	record {
		hostname = "sub"
		type     = "NS"
		address  = "freedns3.registrar-servers.com."
	}
	record {
		hostname = "sub"
		type     = "NS"
		address  = "freedns4.registrar-servers.com."
	}
	record {
		hostname = "sub"
		type     = "NS"
		address  = "freedns5.registrar-servers.com."
	}
}

Debug Output

Panic Output

Expected Behavior

The records for subdomain sub.example.com, including mail setting, are configured to the associated FreeDNS domain sub.example.com. In case that two configs are conflicting, separating the two records in 2 projects and try apply the project with main record first, then apply the project with sub record.

Actual Behavior

The records for subdomain sub.example.com are configured to the root domain example.com.

Steps to Reproduce

  1. terraform apply

Important Factoids

I own the root domain example.com and manage it on namecheap. I also create a FreeDNS domain to manage sub.example.com.

Rationale: I want to customize MX on the subdomain while using email forwarding on the root domain.

References

tranvansang avatar Jan 19 '23 17:01 tranvansang