timohirt / terraform-provider-hetznerdns

Terraform provider for Hetzner DNS
Mozilla Public License 2.0
109 stars 21 forks source link

Issues working with wildcard DNS #30

Open ppacher opened 3 years ago

ppacher commented 3 years ago

I recently wanted to add a new node to my Hetzner cluster. I didn't execute terraform for a while no so I'm still searching if something changed at the Hetzner DNS API. Though, I though I post the issue here.

The first thing that raise my attention was that terraform plan did not correctly refresh the state from the wildcard DNS entry. It was marked "needs creation" while the record is actually there and works (confirmed via Hetzner DNS console). When applying the changes terraform ends with the following error while creating the wildcard entry (TF_LOG=debug was set)

hetznerdns_record.ingress-wildcard: Creating...
2021-11-04T09:32:19.533+0100 [INFO]  Starting apply for hetznerdns_record.ingress-wildcard
2021-11-04T09:32:19.534+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-11-04T09:32:19.536+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hetznercloud/hcloud/1.26.2/linux_amd64/terraform-provider-hcloud_v1.26.2 pid=637694
2021-11-04T09:32:19.536+0100 [DEBUG] provider: plugin exited
2021-11-04T09:32:19.536+0100 [DEBUG] hetznerdns_record.ingress-wildcard: applying the planned Create change
2021-11-04T09:32:19.537+0100 [DEBUG] provider.terraform-provider-hetznerdns_v1.1.1: 2021/11/04 09:32:19 [DEBUG] Updating resource record
2021-11-04T09:32:19.537+0100 [DEBUG] provider.terraform-provider-hetznerdns_v1.1.1: 2021/11/04 09:32:19 [DEBUG] HTTP request to API POST https://dns.hetzner.com/api/v1/records
2021-11-04T09:32:19.725+0100 [DEBUG] provider.terraform-provider-hetznerdns_v1.1.1: 2021/11/04 09:32:19 [ERROR] Error creating DNS record *: Error creating record *: API returned HTTP 422 Unprocessable Entity error with message: '422 Unprocessable Entity: taken  *'

The resource block looks like this:

resource "hetznerdns_record" "ingress-wildcard" {
  zone_id = data.hetznerdns_zone.rootzone.id
  name    = "*"
  type    = "CNAME"
  value   = "ingress.cluster"
  ttl     = var.dns_ttl
}

That block hasn't change for a while now so I'm 100% sure it worked before. Please tell me if I can help further debugging this!

Thanks for this awesome provider!

timohirt commented 2 years ago

I can't reproduce..

image

What is the value of ttl? The Hetzner DNS Api only supports the following ttl as far as I remember. Do you use a TTL of this list?

image

ppacher commented 2 years ago

I'm using a TTL of 60s. Please note that this does not happen on the first run but rather when running terraform again. It fails to detect the existing "wildcard" DNS resource and tries to create a new one. Upon that, Hetzern returns '422 Unprocessable Entity: taken *'