paultyng/terraform-provider-unifi

Bug: Data `unifi_user` cannot get any information other than `id`, even though actual API request returns information

Opened this issue · 0 comments

Hi there,

I've been trying to use the unifi_user data source with this provider, but have been having trouble getting any data from it, even though the API seems to be responding fine.

For context, I'm using version 0.41.0 of the provider, and my UniFi controller (UDM-SE) is running Unifi OS v3.1.15 with network 7.5.174.

This is how I have the provider configured, and the data source:

provider "unifi" {
  username       = data.aws_ssm_parameter.unifi_username.value
  password       = data.aws_ssm_parameter.unifi_password.value
  api_url        = "https://192.168.1.1"
  allow_insecure = true
  site = "default"
}

data "unifi_user" "controlplane_ips" {
  mac = "22:cf:10:e6:48:43"
}

And this is the output I get from the data source:

  "blocked" = false
  "dev_id_override" = 0
  "fixed_ip" = ""
  "hostname" = ""
  "id" = "64f6b3f6ea1aec469ee8fb50"
  "ip" = ""
  "local_dns_record" = tostring(null)
  "mac" = "22:cf:10:e6:48:43"
  "name" = ""
  "network_id" = ""
  "note" = ""
  "site" = "default"
  "user_group_id" = ""

If I make a GET request to https://192.168.1.1/proxy/network/api/s/default/stat/user/22:cf:10:e6:48:43 as the same user, I get a full response as shown:

{
	"meta": {
		"rc": "ok"
	},
	"data": [
		{
			"last_ip": "10.10.0.247",
			"oui": "",
			"first_seen": 1693889526,
			"last_seen": 1693960033,
			"is_guest": false,
			"disconnect_timestamp": 1693957213,
			"is_wired": true,
			"usergroup_id": "",
			"last_connection_network_name": "Lab",
			"mac": "22:cf:10:e6:48:43",
			"last_connection_network_id": "64ed54c2ea1aec469ee66c6e",
			"hostname": "",
			"site_id": "64df3f6335fdab0a83e2c01f",
			"_id": "64f6b3f6ea1aec469ee8fb50",
			"assoc_time": 1693888294,
			"latest_assoc_time": 1693959230,
			"user_id": "64f6b3f6ea1aec469ee8fb50",
			"_uptime_by_ugw": 71739,
			"_last_seen_by_ugw": 1693960032,
			"_is_guest_by_ugw": false,
			"gw_mac": "e4:38:83:22:d6:7c",
			"gw_vlan": 10,
			"network": "Lab",
			"network_id": "64ed54c2ea1aec469ee66c6e",
			"_last_reachable_by_gw": 1693959823,
			"satisfaction_avg": {
				"total": 0,
				"count": 3146
			},
			"uptime": 71739,
			"eagerly_discovered": true,
			"wired-tx_bytes": 941,
			"wired-rx_bytes": 822,
			"wired-tx_packets": 11,
			"wired-rx_packets": 11,
			"wired-tx_bytes-r": 57.57575757575757,
			"wired-rx_bytes-r": 57.57575757575757,
			"tx_retries": 0,
			"wifi_tx_attempts": 0,
			"authorized": true,
			"qos_policy_applied": true,
			"_uptime_by_usw": 803,
			"_last_seen_by_usw": 1693960033,
			"_is_guest_by_usw": false,
			"sw_mac": "b4:fb:e4:29:dc:18",
			"sw_port": 3,
			"wired_rate_mbps": 1000,
			"sw_depth": 1,
			"vlan": 10,
			"hostname_source": "ubios",
			"ip": "10.10.0.247",
			"anomalies": -1
		}
	]
}

Thank you so much for developing this provider by the way, I'm excited to use it with my infra automation!