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

Question: DNS Type for resource #54

Open
vavan11 opened this issue Dec 6, 2021 · 7 comments
Open

Question: DNS Type for resource #54

vavan11 opened this issue Dec 6, 2021 · 7 comments

Comments

@vavan11
Copy link

vavan11 commented Dec 6, 2021

Is it possible to have the ability to add a DNS record type at the mikrotik_dns_record resource?

@ddelnano
Copy link
Owner

ddelnano commented Dec 6, 2021

Unfortunately that is not possible. Please see the docs on static records here, which the provider is using behinds the scenes.

@ddelnano ddelnano closed this as completed Dec 6, 2021
@vavan11
Copy link
Author

vavan11 commented Dec 7, 2021

Thanks for your quick reply.

@theblop
Copy link

theblop commented Mar 20, 2022

@ddelnano The official doc on static records seems to indicate this is possible to specify a record type, so maybe this has changed recently? Being able to manage TXT or SRV records would be useful for example.

@ddelnano
Copy link
Owner

ddelnano commented Mar 21, 2022

From my reading of the release notes, it seems this was supported in v6.47. I thought for sure I didn't see it in the docs when I checked in December, but it does appear that this might be possible now!

Screen Shot 2022-03-20 at 8 38 48 PM

I gave the implementation a try, but it's not clear to me how the value of the non A records are supposed to be passed to the API. The existing address field throws the following error when used with a TXT record (see branch for more details).

ddelnano@ddelnano-desktop:~/go/src/github.com/ddelnano/terraform-provider-mikrotik$ TF_LOG=debug TEST=TestAccMikrotikDnsRecord_createTXTRecord make testacc
TF_ACC=1 TF_LOG=debug go test ./... -run TestAccMikrotikDnsRecord_createTXTRecord -v -count 1 -timeout 40m
?       github.com/ddelnano/terraform-provider-mikrotik [no test files]
=== RUN   TestAccMikrotikDnsRecord_createTXTRecord
=== PAUSE TestAccMikrotikDnsRecord_createTXTRecord
=== CONT  TestAccMikrotikDnsRecord_createTXTRecord
2022/03/20 21:12:58 [WARN] Previously configured provider being re-configured. This can cause issues in concurrent testing if the configurations are not equal.
2022/03/20 21:12:58 [INFO] Running the mikrotik command: `[/ip/dns/static/add =name=dns-01.terraform =ttl=300 =address=google.com. =type=TXT]`
2022/03/20 21:12:58 [DEBUG] /ip/dns/static/add returned !done @ []
2022/03/20 21:12:58 [WARN] Got error running Terraform: exit status 1

Error: from RouterOS device: invalid value for argument address:
    invalid value for argument ip
    invalid value for argument ipv6

  on terraform_plugin_test.tf line 2, in resource "mikrotik_dns_record" "bar":
   2: resource "mikrotik_dns_record" "bar" {


    resource_dns_record_test.go:39: Step 1/1 error: Error running apply: exit status 1

        Error: from RouterOS device: invalid value for argument address:
            invalid value for argument ip
            invalid value for argument ipv6

          on terraform_plugin_test.tf line 2, in resource "mikrotik_dns_record" "bar":
           2: resource "mikrotik_dns_record" "bar" {


--- FAIL: TestAccMikrotikDnsRecord_createTXTRecord (0.65s)
FAIL
FAIL    github.com/ddelnano/terraform-provider-mikrotik/mikrotik        0.663s
?       github.com/ddelnano/terraform-provider-mikrotik/mikrotik/internal       [no test files]
FAIL
make: *** [Makefile:33: testacc] Error 1

So while the mikrotik documentation now says that it's supported, I'm not sure what mikrotik command would result in a successful DNS record.

@theblop
Copy link

theblop commented Mar 22, 2022

I think the argument name depends on the record type, for example the TXT type would use text instead of ip.
Here are all the possible arguments in the cli:

[admin@MikroTik] /ip dns static> add 
address  cname  comment  copy-from  disabled  forward-to  mx-exchange  mx-preference  name  ns  place-before  regexp  srv-port  srv-priority  srv-target  srv-weight  text  ttl  type

@ddelnano
Copy link
Owner

@theblop thanks for pointing this out. That wasn't clear to me from the documentation. This should be possible then.

@ddelnano ddelnano reopened this Mar 26, 2022
@theblop
Copy link

theblop commented Mar 26, 2022

It may not be easy to do a generic "dns_record" resource since the arguments change depending on the type. Maybe we should have different resources by type if it's not easy to have optional arguments in the resource...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants