lxc / terraform-provider-incus

Incus provider for Terraform/OpenTofu
https://linuxcontainers.org/incus
Mozilla Public License 2.0
35 stars 8 forks source link

Add support for network forwards #35

Closed f-bn closed 3 weeks ago

f-bn commented 4 months ago

Hello !

In order to continue the improve the provider, having support of network forward feature could be nice.

Thanks !

stgraber commented 1 month ago

This should be very similar to what's been done for load-balancers: https://registry.terraform.io/providers/lxc/incus/latest/docs/resources/network_load_balancer

The applicable struct is: https://github.com/lxc/incus/blob/main/shared/api/network_forward.go

The network forward entry itself is basically:

Then each port is:

So that should result in a incus_network_forward which looks like this:

resource "incus_network_acl" "this" {
    remote = "my-cluster"
    project = "foo"

    network = "my-network"
    listen_address = "10.0.0.1"
    description = "My network forward"

    config {
        target_address = "10.1.1.10"
    }

    port {
        description = "SSH"
        listen_port = "22"
        target_port = "2022"
        target_address = "10.1.1.1"
    }

    port {
        description = "HTTP"
        listen_port = "80"
        target_port = "8080"
        target_address = "10.1.1.2"
    }
}