Closed bennysp closed 7 months ago
Some resources can not be imported. I think ethernet interfaces are also that type. In my project I could overwrite the settings on the router with terraform without importing.
@jlpedrosa Please tell me, what was the reason to use the filter by interface name and not by its Id? Import does not work:
routeros_interface_ethernet.ether5: Importing from ID "*5"...
routeros_interface_ethernet.ether5: Import prepared!
Prepared routeros_interface_ethernet for import
routeros_interface_ethernet.ether5: Refreshing state... [id=*5]
[DEBUG] provider.terraform-provider-routeros_v1.32.4: GET request URL: https://172.16.3.1/rest/interface/ethernet?default-name=: tf_req_id=30811585-bf86-da11-52ab-0589d0821337 tf_rpc=Configure
[DEBUG] provider.terraform-provider-routeros_v1.32.4: response body: []: @module=routeros tf_provider_addr=terraform-routeros/routeros tf_req_id=30811585-bf86-da11-52ab-0589d0821337 tf_rpc=Configure @
Per the documentation it is importable @durandguru. The documentation shows using ID: https://registry.terraform.io/providers/terraform-routeros/routeros/1.34.0#import
(I will probably do that @durandguru too, but I wanted to report this for awareness too.)
A little patience. There is a small nuance in the implementation of the resource, because of which the import does not work.
@vaerh are you refering to: "findInterfaceByDefaultName" ?
That is how many of the scripts for Mikrotik work (in their samples), as names can be reset/updated, but the underlying factory-name is the same, we use that field to retrieve the actual ID.
filter := buildReadFilter(map[string]interface{}{"default-name": d.Get("factory_name")})
The interface still should be importable by ID, I'm not sure why it's not working, I'm trying to troubleshoot it.
PR in Draft. It works, but I'd like to add an integration test for import so we don't hit this again in the future. https://github.com/terraform-routeros/terraform-provider-routeros/pull/379
Yes, I was referring to that exact function.
The problem is that we can't access to factory_name
when importing. It seems to me that for interfaces, the Id
should not change during the whole functioning time. I could have fixed this yesterday, but I didn't want to break anything.
I'll have a look at the PR on my lab tonight.
The PR is ready for review, forgot to update here. Basically if we have the ID already (import scenario) we don't do the lookup
:tada: This issue has been resolved in version 1.37.1 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
Describe the bug
I have the below setup in terraform:
I have this on the print out in RouterOS:
When I go to run
tofu import routeros_interface_ethernet.ether4 "*6"
andtofu import routeros_interface_ethernet.combo1 "*2"
, I get this error:To Reproduce Please see above.
Expected behavior Expected the import to complete
Stack Trace NA
Additional context I am using RouerOS 7.13 and latest routeros tf provider 1.34,0. I am using OpenTofu, but this happens with Terraform too.