Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routeros_dns_record does not change resource type and data correctly after #158 #159

Closed
javierbertoli opened this issue Mar 12, 2023 · 3 comments · Fixed by #160
Closed
Assignees
Labels
bug Something isn't working released

Comments

@javierbertoli
Copy link

Describe the bug
After #158, when a DNS RR type is changed, the operation apparently adds/changes the new parameters but does not change (or delete) the rest of the resource data consistently, resulting in an inconsistent resource that can't be updated, as it results again in the error described in #150

│ Error: PUT 'https://my.mk/rest/ip/dns/static' returned response code: 400, message: 'Bad Request', details: 'invalid value for argument address:
│     invalid value for argument ip
│     invalid value for argument ipv6'
│ 
│   with routeros_ip_dns_record.new_cname,
│   on dns.tf line 14, in resource "routeros_ip_dns_record" "new_cname":
│   14: resource "routeros_ip_dns_record" "ros" {
│ 

To Reproduce

  1. Create an A record
resource "routeros_ip_dns_record" "a_record" {
  name     = "a.local"
  type     = "A"
  address  = "111.222.333.444"
}
  1. Apply
  2. Change resource type to CNAME
resource "routeros_ip_dns_record" "a_record" {
  name     = "a.local"
  type     = "CNAME"
  cname  = "some.fqdn"
}
  1. Apply (will error)
╷
│ Error: PATCH 'https://my.mk/rest/ip/dns/static/*3' returned response code: 400, message: 'Bad Request', details: 'invalid value for argument address:
│     invalid value for argument ip
│     invalid value for argument ipv6'
│ 
│   with routeros_ip_dns_record.a_record,
│   on dns.tf line 14, in resource "routeros_dns_record" "a_record"":
│   14: resource "routeros_dns_record" "a_record" {
│ 
  1. Check the resulting entry in the state file
$ tf  state show  'routeros_ip_dns_record.a_record'
# routeros_ip_dns_record.a_record:
resource "routeros_ip_dns_record" "a_record" {
    address  = "111.222.333.444"
    cname    = "some.fqdn"
    disabled = false
    dynamic  = false
    id       = "*3"
    name     = "a.local"
    ttl      = "1d"
    type     = "CNAME"
}

where it can be seen that the type was changed, the cname was added but the address was not removed (as it should have been)

Expected behavior
The resource should be updated consistently, according to the resource type.

@gfenn-newbury
Copy link
Collaborator

🎉 This issue has been resolved in version 1.1.8 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@vaerh
Copy link
Collaborator

vaerh commented Mar 12, 2023

Thanks, I missed this moment. Please test the release and I want to draw your attention to the fact that the type field is now mandatory.
And I don't know how you could add a resource with such an interesting address :) "111.222.333.444", I did not immediately understand the reason for the refusal to add the resource and after that I added a validator that this is actually an IP address.

@javierbertoli
Copy link
Author

Thanks! It works ok now.

Re: "111.222.333.444" sorry, my bad 😄 .I usually use such notation (or www.xxx.yyy.zzz) to state that is an IP, and didn't pay much attention to the fact that it was invalid when describing the error. Glad to know you added an extra test for such things!

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
3 participants