terraform-provider-unifi
terraform-provider-unifi copied to clipboard
Terraform import of unifi_device returning error
When importing a unifi_device I am receiving the following error:
terraform import unifi_device.office_switch 'f4:92:bf:8b:7b:65'
unifi_device.office_switch: Importing from ID "f4:92:bf:8b:7b:65"...
Error: unable to decode body: GET s/default/stat/device unable to unmarshal alias: unable to unmarshal alias: json: cannot unmarshal number into Go struct field .ht of type string
Do you have any advice on how to debug the response as this was previously working so I am wondering if this is due to an update of the Unifi Dream Machine's Network Management module.
This may be a bug that was recently fixed in the SDK, hopefully will ship a new version shortly that fixes some of these marshalling issues.
Are you on the latest version of the provider?
Hey Paul,
Yes I am on 0.26.0.
May I ask though... how do you find the API info and debug requests to the API at current? Do you use mitmproxy or something similar?
I am interested in helping to do some development on this provider (and also contemplating working on a Terraform provider of my own) so any advice on how to get started would be appreciated.
Thanks,
Alan Jenkins
Confirmed this on 0.26.0 w/ UDM Pro Firmware 1.8.6 and Network 6.0.43.
I am seeing a similar issue, just with .stp_priority
on 6.2.26 on a self-hosted controller:
❯ terraform import unifi_device.love-loft 74:ac:b9:a8:d6:96
unifi_device.love-loft: Importing from ID "74:ac:b9:a8:d6:96"...
│ Error: unable to decode body: GET s/default/stat/device unable to unmarshal alias: json: cannot unmarshal number into Go struct field .stp_priority of type string
I'm seeing the same issue as @kradalby, when planning:
│ Error: unable to decode body: GET s/default/stat/device unable to unmarshal alias: json: cannot unmarshal number into Go struct field .stp_priority of type string
│
│ with unifi_device.kjokken,
│ on aps.tf line 15, in resource "unifi_device" "kjokken":
│ 15: resource "unifi_device" "kjokken" {
I've enabled STP under Networks in the GUI, and overridden the manual configuration for a switch. Reverting the change gives the same behaviour. Should it be changed to numberOrString
here?
@evenh I think you are correct, when I just inspected my traffic i saw "stp_priority": "32768"
I'll do a quick update and regenerate the SDK and bump the version.
This fix should go out in v0.38.2, I'm not 100% sure it will fix this, but worth a shot!
If it doesn't fix it, just let me know here and I'll reopen it
Confirming this had been an issue and is now fixed in v0.38.2 w/ UDM Pro Firmware 1.12.30 and Network 7.2.94/7.2.95. Thank you!