paultyng/terraform-provider-unifi

Add switch port aggregation support

Cellivar opened this issue · 2 comments

We have a US-24-POE switch that uses link aggregation for a couple of devices. It'd be very nice to be able to configure that setup as part of Terraform, however presently that doesn't appear to work.

I hit "apply" in a similar configuration to the screenshot below, this is the example request that was set to the UDM-P that I use as my controller:

URI: https://unifi.my.network/proxy/network/api/s/default/rest/device/5fa75def5318bd035aa209bd
METHOD: PUT
{
    "port_overrides": [
        {
            "port_idx": 11,
            "portconf_id": "5f3d11ec5318bd051a842c6e",
            "port_security_mac_address": [],
            "op_mode": "aggregate",
            "aggregate_num_ports": 2
        },
        {
            "port_idx": 9,
            "portconf_id": "5f3d11ec5318bd051a842c6e",
            "op_mode": "aggregate",
            "port_security_mac_address": [],
            "aggregate_num_ports": 2
        }
    ]
}

On my machine the portconf_id there is the default "All" configuration as seen here from my terraform state:

data "unifi_port_profile" "all" {
    id   = "5f3d11ec5318bd051a842c6e"
    name = "All"
    site = "default"
}

And the device in the request URI is the US-24-POE, also as seen from my terraform state:

# unifi_device.us_24_poe:
resource "unifi_device" "us_24_poe" {
    disabled = false
    id       = "5fa75def5318bd035aa209bd"
    mac      = "de:vi:ce:ma:cn:um"
    site     = "default"

    port_override {
        number          = 11
        port_profile_id = "5f3d11ec5318bd051a842c6e"
    }
    port_override {
        number          = 9
        port_profile_id = "5f3d11ec5318bd051a842c6e"
    }
}

This doesn't seem too difficult to add, alas I don't know golang very well so I'm not of much use here :)

Let me know if you need any additional details.

Screenshot of relevant configuration:

image

I have a USW-24-PoE as well and I didn't realize this was possible 😅, I'll have to poke around to see what the API request looks like.

Opened #182 to support this. Let me know if it works for you. I can't easily test this without hardware it seems, still trying to figure that out.