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

Updating DNS records throws 400 error #5

Closed danielcompton closed 1 year ago

danielcompton commented 6 years ago

Terraform Version

Terraform v0.10.7

Affected Resource(s)

Terraform Configuration Files

resource "dnsimple_record" "app_v4" {
  domain = "${var.domain}"
  name   = "${var.name}"
  type   = "${var.type}"
  ttl    = "${var.ttl}"
  value  = "${var.value}"
}

Expected Behavior

  1. I updated the name of the domain from test-app to app in my config.
  2. I ran terraform apply
  3. I expected the update to succeed

Actual Behavior

I got an error

* dnsimple_record.app_v4: Failed to update DNSimple Record: PATCH https://api.dnsimple.com/v2/<my-account>/zones/<my-domain>/records/12561018: 400 Validation failed

I suspect what may be happening is that the provider is detecting a change and trying to do a PATCH, but a PATCH is only valid if the value is changing, not if the name is changing.

References

Possibly related to https://github.com/terraform-providers/terraform-provider-dnsimple/issues/1?

weppos commented 6 years ago

@danielcompton my best guess is that you're right, Terraform is trying to send an update but in this case we can't accept the update as you are effectively creating a record for a different domain name (if I understand correct).

The provider should instead either forbit the operation, or automatically delete the records and re-create them in the new domain.

danielcompton commented 6 years ago

I think delete and recreate is the right behaviour here?

weppos commented 1 year ago

I am closing this ticket as it is specific to a validation error. We've made changes to surface the errors, so next time it will be easier to understand the specific issue.