dnsimple / terraform-provider-dnsimple

Terraform DNSimple provider.
https://www.terraform.io/docs/providers/dnsimple/
Mozilla Public License 2.0
22 stars 20 forks source link

Permadiff on dnsimple_domain_delegation when name servers end in . #138

Closed paddycarver closed 6 months ago

paddycarver commented 1 year ago

Terraform Version

v1.5.4

Affected Resource(s)

Terraform Configuration Files

resource "dnsimple_domain" "my_domain" {
  name = "dnsimple.com"
}

resource "google_dns_managed_zone" "my_domain" {
  name        = "my-domain"
  dns_name    = "dnsimple.com."
}

resource "dnsimple_domain_delegation" "my_domain" {
  domain       = dnsimple_domain.my_domain.name
  name_servers = google_dns_managed_zone.my_domain.name_servers
}

Debug Output

Available upon request, but shouldn't be necessary.

Expected Behavior

After first apply, no changes show up in plan.

Actual Behavior

  # dnsimple_domain_delegation.my_domain must be replaced
-/+ resource "dnsimple_domain_delegation" "my_domain" {
      ~ id           = "dnsimple.com" -> (known after apply)
      ~ name_servers = [ # forces replacement
          - "ns-cloud-e1.googledomains.com",
          - "ns-cloud-e2.googledomains.com",
          - "ns-cloud-e3.googledomains.com",
          - "ns-cloud-e4.googledomains.com",
          + "ns-cloud-e1.googledomains.com.",
          + "ns-cloud-e2.googledomains.com.",
          + "ns-cloud-e3.googledomains.com.",
          + "ns-cloud-e4.googledomains.com.",
        ]
        # (1 unchanged attribute hidden)
    }

Steps to Reproduce

  1. terraform apply
  2. terraform apply

Other

I'm happy to open a PR to address this issue, if it would help. I believe the plan just needs to be modified to treat the name server list values as equal if they match except for a trailing .. The alternative is for the API to return the values as they're provided, or for the API (or provider) to reject nameservers that end in . as invalid, if it's going to canonicalize them anyways.

DXTimer commented 1 year ago

Thank you for taking the time to report this @paddycarver. I agree adding a validation to the resource can be a good first step. We will work on this in the coming weeks.

paddycarver commented 1 year ago

For those doing this that want the answer without provider changes, if you change your config to this:

resource "dnsimple_domain" "my_domain" {
  name = "dnsimple.com"
}

resource "google_dns_managed_zone" "my_domain" {
  name        = "my-domain"
  dns_name    = "dnsimple.com."
}

resource "dnsimple_domain_delegation" "my_domain" {
  domain       = dnsimple_domain.my_domain.name
  name_servers = [for s in google_dns_managed_zone.my_domain.name_servers : trimsuffix(s, ".")]
}

it works.

weppos commented 8 months ago

@DXTimer please provide an update as planned.