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 network forward resource #87

Closed maveonair closed 1 week ago

maveonair commented 1 week ago

This pull requests adds the network forward resource (see https://github.com/lxc/terraform-provider-incus/issues/35).

Examples

resource "incus_network" "my_network" {
  name = "my-network"

  config = {
    "ipv4.address" = "10.150.19.1/24"
    "ipv4.nat"     = "true"
    "ipv6.address" = "fd42:474b:622d:259d::1/64"
    "ipv6.nat"     = "true"
  }
}

resource "incus_network_forward" "my_forward" {
  network        = incus_network.my_network.name
  listen_address = "10.150.19.10"

  config = {
    target_address = "10.150.19.111"
  }

  ports = [
    {
      description    = "SSH"
      protocol       = "tcp"
      listen_port    = "22"
      target_port    = "2022"
      target_address = "10.150.19.112"
    },
    {
      description    = "HTTP"
      protocol       = "tcp"
      listen_port    = "80"
      target_port    = "8080"
      target_address = "10.150.19.112"
    }
  ]
}

What's been done

stgraber commented 1 week ago

Looking great, just a couple of nits on the imports and we'll be good to merge!