diff --git a/docs/resources/virtual_environment_network_linux_vlan.md b/docs/resources/virtual_environment_network_linux_vlan.md index 9dd69b89..e435d416 100644 --- a/docs/resources/virtual_environment_network_linux_vlan.md +++ b/docs/resources/virtual_environment_network_linux_vlan.md @@ -14,12 +14,23 @@ Manages a Linux VLAN network interface in a Proxmox VE node. ## Example Usage ```terraform +# using VLAN tag resource "proxmox_virtual_environment_network_linux_vlan" "vlan99" { node_name = "pve" name = "eno0.99" comment = "VLAN 99" } + +# using custom network interface name +resource "proxmox_virtual_environment_network_linux_vlan" "vlan98" { + node_name = "pve" + name = "vlan_lab" + + interface = "eno0" + vlan = 98 + comment = "VLAN 98" +} ``` @@ -27,7 +38,7 @@ resource "proxmox_virtual_environment_network_linux_vlan" "vlan99" { ### Required -- `name` (String) The interface name. Add the VLAN tag number to an existing interface name, e.g. `ens18.21` +- `name` (String) The interface name. Either add the VLAN tag number to an existing interface name, e.g. `ens18.21` (and do not set `interface` and `vlan`), or use custom name, e.g. `vlan_lab` (`interface` and `vlan` are then required). - `node_name` (String) The name of the node. ### Optional @@ -38,13 +49,13 @@ resource "proxmox_virtual_environment_network_linux_vlan" "vlan99" { - `comment` (String) Comment for the interface. - `gateway` (String) Default gateway address. - `gateway6` (String) Default IPv6 gateway address. +- `interface` (String) The VLAN raw device. See also `name`. - `mtu` (Number) The interface MTU. +- `vlan` (Number) The VLAN tag. See also `name`. ### Read-Only -- `id` (String) A unique identifier with format ':' -- `interface` (String) The VLAN raw device. -- `vlan` (Number) The VLAN tag +- `id` (String) A unique identifier with format ':'. ## Import diff --git a/examples/resources/proxmox_virtual_environment_network_linux_vlan/resource.tf b/examples/resources/proxmox_virtual_environment_network_linux_vlan/resource.tf index 663c38be..c8152a0e 100644 --- a/examples/resources/proxmox_virtual_environment_network_linux_vlan/resource.tf +++ b/examples/resources/proxmox_virtual_environment_network_linux_vlan/resource.tf @@ -1,6 +1,17 @@ +# using VLAN tag resource "proxmox_virtual_environment_network_linux_vlan" "vlan99" { node_name = "pve" name = "eno0.99" comment = "VLAN 99" } + +# using custom network interface name +resource "proxmox_virtual_environment_network_linux_vlan" "vlan98" { + node_name = "pve" + name = "vlan_lab" + + interface = "eno0" + vlan = 98 + comment = "VLAN 98" +} diff --git a/internal/network/resource_linux_vlan.go b/internal/network/resource_linux_vlan.go index 100f0228..8c10d1f7 100644 --- a/internal/network/resource_linux_vlan.go +++ b/internal/network/resource_linux_vlan.go @@ -148,16 +148,18 @@ func (r *linuxVLANResource) Schema( PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, - Description: "A unique identifier with format ':'", + Description: "A unique identifier with format ':'.", }, "node_name": schema.StringAttribute{ Description: "The name of the node.", Required: true, }, "name": schema.StringAttribute{ - Description: "The interface name.", - MarkdownDescription: "The interface name. Add the VLAN tag number to an existing interface name, e.g. `ens18.21`", - Required: true, + Description: "The interface name.", + MarkdownDescription: "The interface name. Either add the VLAN tag number to an existing interface name, " + + "e.g. `ens18.21` (and do not set `interface` and `vlan`), or use custom name, e.g. `vlan_lab` " + + "(`interface` and `vlan` are then required).", + Required: true, Validators: []validator.String{ stringvalidator.LengthAtLeast(3), }, @@ -202,13 +204,13 @@ func (r *linuxVLANResource) Schema( }, // Linux VLAN attributes "interface": schema.StringAttribute{ - // read-only - Description: "The VLAN raw device.", + Description: "The VLAN raw device. See also `name`.", + Optional: true, Computed: true, }, "vlan": schema.Int64Attribute{ - // read-only - Description: "The VLAN tag", + Description: "The VLAN tag. See also `name`.", + Optional: true, Computed: true, }, }, diff --git a/proxmox/nodes/network_types.go b/proxmox/nodes/network_types.go index 59e393e1..55f47680 100644 --- a/proxmox/nodes/network_types.go +++ b/proxmox/nodes/network_types.go @@ -76,7 +76,7 @@ type NetworkInterfaceCreateUpdateRequestBody struct { OVSPorts *string `json:"ovs_ports,omitempty" url:"ovs_ports,omitempty"` OVSTag *string `json:"ovs_tag,omitempty" url:"ovs_tag,omitempty"` Slaves *string `json:"slaves,omitempty" url:"slaves,omitempty"` - VLANID *int64 `json:"vlan_id,omitempty" url:"vlan_id,omitempty"` + VLANID *int64 `json:"vlan-id,omitempty" url:"vlan-id,omitempty"` VLANRawDevice *string `json:"vlan-raw-device,omitempty" url:"vlan-raw-device,omitempty"` }