namecheap / terraform-provider-namecheap

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

FreeDNS subdomain records are all incorrectly going to the root domain #71

Open tranvansang opened 1 year ago

tranvansang commented 1 year ago

Terraform Version

Terraform v1.3.3
on linux_amd64

Namecheap provider version

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

Affected Resource(s)

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

ensosystems commented 10 months ago

I'm currently experiencing the same behavior.

I reached out to the support team just to make sure there are no workarounds. It seems there are no workarounds for this.