1. Packages
  2. Openwrt Provider
  3. API Docs
  4. NetworkSwitchVlan
openwrt 0.0.20 published on Friday, Mar 7, 2025 by joneshf

openwrt.NetworkSwitchVlan

Explore with Pulumi AI

Legacy VLAN configuration

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as openwrt from "@pulumi/openwrt";

const testingNetworkSwitch = new openwrt.NetworkSwitch("testingNetworkSwitch", {
    enableVlan: true,
    networkSwitchId: "testing",
});
const testingNetworkSwitchVlan = new openwrt.NetworkSwitchVlan("testingNetworkSwitchVlan", {
    device: testingNetworkSwitch.name,
    networkSwitchVlanId: "testing",
    ports: "0t 1t",
    vid: 10,
    vlan: 2,
});
Copy
import pulumi
import pulumi_openwrt as openwrt

testing_network_switch = openwrt.NetworkSwitch("testingNetworkSwitch",
    enable_vlan=True,
    network_switch_id="testing")
testing_network_switch_vlan = openwrt.NetworkSwitchVlan("testingNetworkSwitchVlan",
    device=testing_network_switch.name,
    network_switch_vlan_id="testing",
    ports="0t 1t",
    vid=10,
    vlan=2)
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/openwrt/openwrt"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		testingNetworkSwitch, err := openwrt.NewNetworkSwitch(ctx, "testingNetworkSwitch", &openwrt.NetworkSwitchArgs{
			EnableVlan:      pulumi.Bool(true),
			NetworkSwitchId: pulumi.String("testing"),
		})
		if err != nil {
			return err
		}
		_, err = openwrt.NewNetworkSwitchVlan(ctx, "testingNetworkSwitchVlan", &openwrt.NetworkSwitchVlanArgs{
			Device:              testingNetworkSwitch.Name,
			NetworkSwitchVlanId: pulumi.String("testing"),
			Ports:               pulumi.String("0t 1t"),
			Vid:                 pulumi.Float64(10),
			Vlan:                pulumi.Float64(2),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Openwrt = Pulumi.Openwrt;

return await Deployment.RunAsync(() => 
{
    var testingNetworkSwitch = new Openwrt.NetworkSwitch("testingNetworkSwitch", new()
    {
        EnableVlan = true,
        NetworkSwitchId = "testing",
    });

    var testingNetworkSwitchVlan = new Openwrt.NetworkSwitchVlan("testingNetworkSwitchVlan", new()
    {
        Device = testingNetworkSwitch.Name,
        NetworkSwitchVlanId = "testing",
        Ports = "0t 1t",
        Vid = 10,
        Vlan = 2,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openwrt.NetworkSwitch;
import com.pulumi.openwrt.NetworkSwitchArgs;
import com.pulumi.openwrt.NetworkSwitchVlan;
import com.pulumi.openwrt.NetworkSwitchVlanArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var testingNetworkSwitch = new NetworkSwitch("testingNetworkSwitch", NetworkSwitchArgs.builder()
            .enableVlan(true)
            .networkSwitchId("testing")
            .build());

        var testingNetworkSwitchVlan = new NetworkSwitchVlan("testingNetworkSwitchVlan", NetworkSwitchVlanArgs.builder()
            .device(testingNetworkSwitch.name())
            .networkSwitchVlanId("testing")
            .ports("0t 1t")
            .vid("10")
            .vlan("2")
            .build());

    }
}
Copy
resources:
  testingNetworkSwitch:
    type: openwrt:NetworkSwitch
    properties:
      enableVlan: true
      networkSwitchId: testing
  testingNetworkSwitchVlan:
    type: openwrt:NetworkSwitchVlan
    properties:
      device: ${testingNetworkSwitch.name}
      networkSwitchVlanId: testing
      ports: 0t 1t
      vid: '10'
      vlan: '2'
Copy

Create NetworkSwitchVlan Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new NetworkSwitchVlan(name: string, args: NetworkSwitchVlanArgs, opts?: CustomResourceOptions);
@overload
def NetworkSwitchVlan(resource_name: str,
                      args: NetworkSwitchVlanArgs,
                      opts: Optional[ResourceOptions] = None)

@overload
def NetworkSwitchVlan(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      device: Optional[str] = None,
                      network_switch_vlan_id: Optional[str] = None,
                      ports: Optional[str] = None,
                      vlan: Optional[float] = None,
                      description: Optional[str] = None,
                      vid: Optional[float] = None)
func NewNetworkSwitchVlan(ctx *Context, name string, args NetworkSwitchVlanArgs, opts ...ResourceOption) (*NetworkSwitchVlan, error)
public NetworkSwitchVlan(string name, NetworkSwitchVlanArgs args, CustomResourceOptions? opts = null)
public NetworkSwitchVlan(String name, NetworkSwitchVlanArgs args)
public NetworkSwitchVlan(String name, NetworkSwitchVlanArgs args, CustomResourceOptions options)
type: openwrt:NetworkSwitchVlan
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. NetworkSwitchVlanArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. NetworkSwitchVlanArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. NetworkSwitchVlanArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. NetworkSwitchVlanArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. NetworkSwitchVlanArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var networkSwitchVlanResource = new Openwrt.NetworkSwitchVlan("networkSwitchVlanResource", new()
{
    Device = "string",
    NetworkSwitchVlanId = "string",
    Ports = "string",
    Vlan = 0,
    Description = "string",
    Vid = 0,
});
Copy
example, err := openwrt.NewNetworkSwitchVlan(ctx, "networkSwitchVlanResource", &openwrt.NetworkSwitchVlanArgs{
	Device:              pulumi.String("string"),
	NetworkSwitchVlanId: pulumi.String("string"),
	Ports:               pulumi.String("string"),
	Vlan:                pulumi.Float64(0),
	Description:         pulumi.String("string"),
	Vid:                 pulumi.Float64(0),
})
Copy
var networkSwitchVlanResource = new NetworkSwitchVlan("networkSwitchVlanResource", NetworkSwitchVlanArgs.builder()
    .device("string")
    .networkSwitchVlanId("string")
    .ports("string")
    .vlan(0)
    .description("string")
    .vid(0)
    .build());
Copy
network_switch_vlan_resource = openwrt.NetworkSwitchVlan("networkSwitchVlanResource",
    device="string",
    network_switch_vlan_id="string",
    ports="string",
    vlan=0,
    description="string",
    vid=0)
Copy
const networkSwitchVlanResource = new openwrt.NetworkSwitchVlan("networkSwitchVlanResource", {
    device: "string",
    networkSwitchVlanId: "string",
    ports: "string",
    vlan: 0,
    description: "string",
    vid: 0,
});
Copy
type: openwrt:NetworkSwitchVlan
properties:
    description: string
    device: string
    networkSwitchVlanId: string
    ports: string
    vid: 0
    vlan: 0
Copy

NetworkSwitchVlan Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The NetworkSwitchVlan resource accepts the following input properties:

Device This property is required. string
The switch to configure.
NetworkSwitchVlanId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
Ports This property is required. string
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
Vlan This property is required. double
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
Description string
A human-readable description of the VLAN configuration.
Vid double
The VLAN tag number to use.
Device This property is required. string
The switch to configure.
NetworkSwitchVlanId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
Ports This property is required. string
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
Vlan This property is required. float64
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
Description string
A human-readable description of the VLAN configuration.
Vid float64
The VLAN tag number to use.
device This property is required. String
The switch to configure.
networkSwitchVlanId This property is required. String
Name of the section. This name is only used when interacting with UCI directly.
ports This property is required. String
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vlan This property is required. Double
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description String
A human-readable description of the VLAN configuration.
vid Double
The VLAN tag number to use.
device This property is required. string
The switch to configure.
networkSwitchVlanId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
ports This property is required. string
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vlan This property is required. number
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description string
A human-readable description of the VLAN configuration.
vid number
The VLAN tag number to use.
device This property is required. str
The switch to configure.
network_switch_vlan_id This property is required. str
Name of the section. This name is only used when interacting with UCI directly.
ports This property is required. str
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vlan This property is required. float
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description str
A human-readable description of the VLAN configuration.
vid float
The VLAN tag number to use.
device This property is required. String
The switch to configure.
networkSwitchVlanId This property is required. String
Name of the section. This name is only used when interacting with UCI directly.
ports This property is required. String
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vlan This property is required. Number
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description String
A human-readable description of the VLAN configuration.
vid Number
The VLAN tag number to use.

Outputs

All input properties are implicitly available as output properties. Additionally, the NetworkSwitchVlan resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing NetworkSwitchVlan Resource

Get an existing NetworkSwitchVlan resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NetworkSwitchVlanState, opts?: CustomResourceOptions): NetworkSwitchVlan
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        device: Optional[str] = None,
        network_switch_vlan_id: Optional[str] = None,
        ports: Optional[str] = None,
        vid: Optional[float] = None,
        vlan: Optional[float] = None) -> NetworkSwitchVlan
func GetNetworkSwitchVlan(ctx *Context, name string, id IDInput, state *NetworkSwitchVlanState, opts ...ResourceOption) (*NetworkSwitchVlan, error)
public static NetworkSwitchVlan Get(string name, Input<string> id, NetworkSwitchVlanState? state, CustomResourceOptions? opts = null)
public static NetworkSwitchVlan get(String name, Output<String> id, NetworkSwitchVlanState state, CustomResourceOptions options)
resources:  _:    type: openwrt:NetworkSwitchVlan    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Description string
A human-readable description of the VLAN configuration.
Device string
The switch to configure.
NetworkSwitchVlanId string
Name of the section. This name is only used when interacting with UCI directly.
Ports string
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
Vid double
The VLAN tag number to use.
Vlan double
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
Description string
A human-readable description of the VLAN configuration.
Device string
The switch to configure.
NetworkSwitchVlanId string
Name of the section. This name is only used when interacting with UCI directly.
Ports string
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
Vid float64
The VLAN tag number to use.
Vlan float64
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description String
A human-readable description of the VLAN configuration.
device String
The switch to configure.
networkSwitchVlanId String
Name of the section. This name is only used when interacting with UCI directly.
ports String
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vid Double
The VLAN tag number to use.
vlan Double
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description string
A human-readable description of the VLAN configuration.
device string
The switch to configure.
networkSwitchVlanId string
Name of the section. This name is only used when interacting with UCI directly.
ports string
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vid number
The VLAN tag number to use.
vlan number
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description str
A human-readable description of the VLAN configuration.
device str
The switch to configure.
network_switch_vlan_id str
Name of the section. This name is only used when interacting with UCI directly.
ports str
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vid float
The VLAN tag number to use.
vlan float
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI
description String
A human-readable description of the VLAN configuration.
device String
The switch to configure.
networkSwitchVlanId String
Name of the section. This name is only used when interacting with UCI directly.
ports String
A string of space-separated port indicies that should be associated with the VLAN. Adding the suffix "t" to a port indicates that egress packets should be tagged, for example "0 1 3t 5t".
vid Number
The VLAN tag number to use.
vlan Number
The VLAN "table index" to configure. This index corresponds to the order on LuCI's UI

Import

Find the Terraform id from LuCI’s JSON-RPC API.

One way to find this information is with curl and jq:

curl \

--data '{"id": 0, "method": "foreach", "params": ["network", "switch_vlan"]}' \

http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \

| jq '.result | map({terraformId: .[".name"]})'

This command will output something like:

[

{

"terraformId": "cfg123456",

},

{

"terraformId": "cfg123457",

}

]

We’d then use the information to import the appropriate resource:

$ pulumi import openwrt:index/networkSwitchVlan:NetworkSwitchVlan administration cfg123456
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
openwrt joneshf/terraform-provider-openwrt
License
Notes
This Pulumi package is based on the openwrt Terraform Provider.