Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

PortVlanAttachment

Provides a resource to attach device ports to VLANs.

Device and VLAN must be in the same facility.

If you need this resource to add the port back to bond on removal, set force_bond = true.

To learn more about Layer 2 networking in Packet, refer to

Example Usage

using Pulumi;
using Packet = Pulumi.Packet;

class MyStack : Stack
{
    public MyStack()
    {
        // Hybrid network type
        var testVlan = new Packet.Vlan("testVlan", new Packet.VlanArgs
        {
            Description = "VLAN in New Jersey",
            Facility = "ewr1",
            ProjectId = local.Project_id,
        });
        var testDevice = new Packet.Device("testDevice", new Packet.DeviceArgs
        {
            Hostname = "test",
            Plan = "m1.xlarge.x86",
            Facilities = 
            {
                "ewr1",
            },
            OperatingSystem = "ubuntu_16_04",
            BillingCycle = "hourly",
            ProjectId = local.Project_id,
        });
        var testDeviceNetworkType = new Packet.DeviceNetworkType("testDeviceNetworkType", new Packet.DeviceNetworkTypeArgs
        {
            DeviceId = testDevice.Id,
            Type = "hybrid",
        });
        var testPortVlanAttachment = new Packet.PortVlanAttachment("testPortVlanAttachment", new Packet.PortVlanAttachmentArgs
        {
            DeviceId = testDeviceNetworkType.Id,
            PortName = "eth1",
            VlanVnid = testVlan.Vxlan,
        });
        // Layer 2 network
        var testIndex_deviceDevice = new Packet.Device("testIndex/deviceDevice", new Packet.DeviceArgs
        {
            Hostname = "test",
            Plan = "m1.xlarge.x86",
            Facilities = 
            {
                "ewr1",
            },
            OperatingSystem = "ubuntu_16_04",
            BillingCycle = "hourly",
            ProjectId = local.Project_id,
        });
        var testIndex_deviceNetworkTypeDeviceNetworkType = new Packet.DeviceNetworkType("testIndex/deviceNetworkTypeDeviceNetworkType", new Packet.DeviceNetworkTypeArgs
        {
            DeviceId = testDevice.Id,
            Type = "layer2-individual",
        });
        var test1Vlan = new Packet.Vlan("test1Vlan", new Packet.VlanArgs
        {
            Description = "VLAN in New Jersey",
            Facility = "ewr1",
            ProjectId = local.Project_id,
        });
        var test2Vlan = new Packet.Vlan("test2Vlan", new Packet.VlanArgs
        {
            Description = "VLAN in New Jersey",
            Facility = "ewr1",
            ProjectId = local.Project_id,
        });
        var test1PortVlanAttachment = new Packet.PortVlanAttachment("test1PortVlanAttachment", new Packet.PortVlanAttachmentArgs
        {
            DeviceId = testDeviceNetworkType.Id,
            VlanVnid = test1Vlan.Vxlan,
            PortName = "eth1",
        });
        var test2PortVlanAttachment = new Packet.PortVlanAttachment("test2PortVlanAttachment", new Packet.PortVlanAttachmentArgs
        {
            DeviceId = testDeviceNetworkType.Id,
            VlanVnid = test2Vlan.Vxlan,
            PortName = "eth1",
            Native = true,
        }, new CustomResourceOptions
        {
            DependsOn = 
            {
                "packet_port_vlan_attachment.test1",
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-packet/sdk/v3/go/packet"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        testVlan, err := packet.NewVlan(ctx, "testVlan", &packet.VlanArgs{
            Description: pulumi.String("VLAN in New Jersey"),
            Facility:    pulumi.String("ewr1"),
            ProjectId:   pulumi.Any(local.Project_id),
        })
        if err != nil {
            return err
        }
        testDevice, err := packet.NewDevice(ctx, "testDevice", &packet.DeviceArgs{
            Hostname: pulumi.String("test"),
            Plan:     pulumi.String("m1.xlarge.x86"),
            Facilities: pulumi.StringArray{
                pulumi.String("ewr1"),
            },
            OperatingSystem: pulumi.String("ubuntu_16_04"),
            BillingCycle:    pulumi.String("hourly"),
            ProjectId:       pulumi.Any(local.Project_id),
        })
        if err != nil {
            return err
        }
        testDeviceNetworkType, err := packet.NewDeviceNetworkType(ctx, "testDeviceNetworkType", &packet.DeviceNetworkTypeArgs{
            DeviceId: testDevice.ID(),
            Type:     pulumi.String("hybrid"),
        })
        if err != nil {
            return err
        }
        _, err = packet.NewPortVlanAttachment(ctx, "testPortVlanAttachment", &packet.PortVlanAttachmentArgs{
            DeviceId: testDeviceNetworkType.ID(),
            PortName: pulumi.String("eth1"),
            VlanVnid: testVlan.Vxlan,
        })
        if err != nil {
            return err
        }
        _, err = packet.NewDevice(ctx, "testIndex_deviceDevice", &packet.DeviceArgs{
            Hostname: pulumi.String("test"),
            Plan:     pulumi.String("m1.xlarge.x86"),
            Facilities: pulumi.StringArray{
                pulumi.String("ewr1"),
            },
            OperatingSystem: pulumi.String("ubuntu_16_04"),
            BillingCycle:    pulumi.String("hourly"),
            ProjectId:       pulumi.Any(local.Project_id),
        })
        if err != nil {
            return err
        }
        _, err = packet.NewDeviceNetworkType(ctx, "testIndex_deviceNetworkTypeDeviceNetworkType", &packet.DeviceNetworkTypeArgs{
            DeviceId: testDevice.ID(),
            Type:     pulumi.String("layer2-individual"),
        })
        if err != nil {
            return err
        }
        test1Vlan, err := packet.NewVlan(ctx, "test1Vlan", &packet.VlanArgs{
            Description: pulumi.String("VLAN in New Jersey"),
            Facility:    pulumi.String("ewr1"),
            ProjectId:   pulumi.Any(local.Project_id),
        })
        if err != nil {
            return err
        }
        test2Vlan, err := packet.NewVlan(ctx, "test2Vlan", &packet.VlanArgs{
            Description: pulumi.String("VLAN in New Jersey"),
            Facility:    pulumi.String("ewr1"),
            ProjectId:   pulumi.Any(local.Project_id),
        })
        if err != nil {
            return err
        }
        _, err = packet.NewPortVlanAttachment(ctx, "test1PortVlanAttachment", &packet.PortVlanAttachmentArgs{
            DeviceId: testDeviceNetworkType.ID(),
            VlanVnid: test1Vlan.Vxlan,
            PortName: pulumi.String("eth1"),
        })
        if err != nil {
            return err
        }
        _, err = packet.NewPortVlanAttachment(ctx, "test2PortVlanAttachment", &packet.PortVlanAttachmentArgs{
            DeviceId: testDeviceNetworkType.ID(),
            VlanVnid: test2Vlan.Vxlan,
            PortName: pulumi.String("eth1"),
            Native:   pulumi.Bool(true),
        }, pulumi.DependsOn([]pulumi.Resource{
            "packet_port_vlan_attachment.test1",
        }))
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_packet as packet

# Hybrid network type
test_vlan = packet.Vlan("testVlan",
    description="VLAN in New Jersey",
    facility="ewr1",
    project_id=local["project_id"])
test_device = packet.Device("testDevice",
    hostname="test",
    plan="m1.xlarge.x86",
    facilities=["ewr1"],
    operating_system="ubuntu_16_04",
    billing_cycle="hourly",
    project_id=local["project_id"])
test_device_network_type = packet.DeviceNetworkType("testDeviceNetworkType",
    device_id=test_device.id,
    type="hybrid")
test_port_vlan_attachment = packet.PortVlanAttachment("testPortVlanAttachment",
    device_id=test_device_network_type.id,
    port_name="eth1",
    vlan_vnid=test_vlan.vxlan)
# Layer 2 network
test_index_device_device = packet.Device("testIndex/deviceDevice",
    hostname="test",
    plan="m1.xlarge.x86",
    facilities=["ewr1"],
    operating_system="ubuntu_16_04",
    billing_cycle="hourly",
    project_id=local["project_id"])
test_index_device_network_type_device_network_type = packet.DeviceNetworkType("testIndex/deviceNetworkTypeDeviceNetworkType",
    device_id=test_device.id,
    type="layer2-individual")
test1_vlan = packet.Vlan("test1Vlan",
    description="VLAN in New Jersey",
    facility="ewr1",
    project_id=local["project_id"])
test2_vlan = packet.Vlan("test2Vlan",
    description="VLAN in New Jersey",
    facility="ewr1",
    project_id=local["project_id"])
test1_port_vlan_attachment = packet.PortVlanAttachment("test1PortVlanAttachment",
    device_id=test_device_network_type.id,
    vlan_vnid=test1_vlan.vxlan,
    port_name="eth1")
test2_port_vlan_attachment = packet.PortVlanAttachment("test2PortVlanAttachment",
    device_id=test_device_network_type.id,
    vlan_vnid=test2_vlan.vxlan,
    port_name="eth1",
    native=True,
    opts=ResourceOptions(depends_on=["packet_port_vlan_attachment.test1"]))
import * as pulumi from "@pulumi/pulumi";
import * as packet from "@pulumi/packet";

// Hybrid network type
const testVlan = new packet.Vlan("testVlan", {
    description: "VLAN in New Jersey",
    facility: "ewr1",
    projectId: local.project_id,
});
const testDevice = new packet.Device("testDevice", {
    hostname: "test",
    plan: "m1.xlarge.x86",
    facilities: ["ewr1"],
    operatingSystem: "ubuntu_16_04",
    billingCycle: "hourly",
    projectId: local.project_id,
});
const testDeviceNetworkType = new packet.DeviceNetworkType("testDeviceNetworkType", {
    deviceId: testDevice.id,
    type: "hybrid",
});
const testPortVlanAttachment = new packet.PortVlanAttachment("testPortVlanAttachment", {
    deviceId: testDeviceNetworkType.id,
    portName: "eth1",
    vlanVnid: testVlan.vxlan,
});
// Layer 2 network
const testIndex_deviceDevice = new packet.Device("testIndex/deviceDevice", {
    hostname: "test",
    plan: "m1.xlarge.x86",
    facilities: ["ewr1"],
    operatingSystem: "ubuntu_16_04",
    billingCycle: "hourly",
    projectId: local.project_id,
});
const testIndex_deviceNetworkTypeDeviceNetworkType = new packet.DeviceNetworkType("testIndex/deviceNetworkTypeDeviceNetworkType", {
    deviceId: testDevice.id,
    type: "layer2-individual",
});
const test1Vlan = new packet.Vlan("test1Vlan", {
    description: "VLAN in New Jersey",
    facility: "ewr1",
    projectId: local.project_id,
});
const test2Vlan = new packet.Vlan("test2Vlan", {
    description: "VLAN in New Jersey",
    facility: "ewr1",
    projectId: local.project_id,
});
const test1PortVlanAttachment = new packet.PortVlanAttachment("test1PortVlanAttachment", {
    deviceId: testDeviceNetworkType.id,
    vlanVnid: test1Vlan.vxlan,
    portName: "eth1",
});
const test2PortVlanAttachment = new packet.PortVlanAttachment("test2PortVlanAttachment", {
    deviceId: testDeviceNetworkType.id,
    vlanVnid: test2Vlan.vxlan,
    portName: "eth1",
    native: true,
}, {
    dependsOn: ["packet_port_vlan_attachment.test1"],
});

Create a PortVlanAttachment Resource

new PortVlanAttachment(name: string, args: PortVlanAttachmentArgs, opts?: CustomResourceOptions);
def PortVlanAttachment(resource_name: str, opts: Optional[ResourceOptions] = None, device_id: Optional[str] = None, force_bond: Optional[bool] = None, native: Optional[bool] = None, port_name: Optional[str] = None, vlan_vnid: Optional[int] = None)
func NewPortVlanAttachment(ctx *Context, name string, args PortVlanAttachmentArgs, opts ...ResourceOption) (*PortVlanAttachment, error)
public PortVlanAttachment(string name, PortVlanAttachmentArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args PortVlanAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args PortVlanAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args PortVlanAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

PortVlanAttachment Resource Properties

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

Inputs

The PortVlanAttachment resource accepts the following input properties:

DeviceId string

ID of device to be assigned to the VLAN

PortName string

Name of network port to be assigned to the VLAN

VlanVnid int

VXLAN Network Identifier, integer

ForceBond bool

Add port back to the bond when this resource is removed. Default is false.

Native bool

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

DeviceId string

ID of device to be assigned to the VLAN

PortName string

Name of network port to be assigned to the VLAN

VlanVnid int

VXLAN Network Identifier, integer

ForceBond bool

Add port back to the bond when this resource is removed. Default is false.

Native bool

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

deviceId string

ID of device to be assigned to the VLAN

portName string

Name of network port to be assigned to the VLAN

vlanVnid number

VXLAN Network Identifier, integer

forceBond boolean

Add port back to the bond when this resource is removed. Default is false.

native boolean

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

device_id str

ID of device to be assigned to the VLAN

port_name str

Name of network port to be assigned to the VLAN

vlan_vnid int

VXLAN Network Identifier, integer

force_bond bool

Add port back to the bond when this resource is removed. Default is false.

native bool

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
PortId string
VlanId string
Id string
The provider-assigned unique ID for this managed resource.
PortId string
VlanId string
id string
The provider-assigned unique ID for this managed resource.
portId string
vlanId string
id str
The provider-assigned unique ID for this managed resource.
port_id str
vlan_id str

Look up an Existing PortVlanAttachment Resource

Get an existing PortVlanAttachment 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?: PortVlanAttachmentState, opts?: CustomResourceOptions): PortVlanAttachment
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, device_id: Optional[str] = None, force_bond: Optional[bool] = None, native: Optional[bool] = None, port_id: Optional[str] = None, port_name: Optional[str] = None, vlan_id: Optional[str] = None, vlan_vnid: Optional[int] = None) -> PortVlanAttachment
func GetPortVlanAttachment(ctx *Context, name string, id IDInput, state *PortVlanAttachmentState, opts ...ResourceOption) (*PortVlanAttachment, error)
public static PortVlanAttachment Get(string name, Input<string> id, PortVlanAttachmentState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
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
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
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
The unique name of the resulting resource.
id
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:

DeviceId string

ID of device to be assigned to the VLAN

ForceBond bool

Add port back to the bond when this resource is removed. Default is false.

Native bool

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

PortId string
PortName string

Name of network port to be assigned to the VLAN

VlanId string
VlanVnid int

VXLAN Network Identifier, integer

DeviceId string

ID of device to be assigned to the VLAN

ForceBond bool

Add port back to the bond when this resource is removed. Default is false.

Native bool

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

PortId string
PortName string

Name of network port to be assigned to the VLAN

VlanId string
VlanVnid int

VXLAN Network Identifier, integer

deviceId string

ID of device to be assigned to the VLAN

forceBond boolean

Add port back to the bond when this resource is removed. Default is false.

native boolean

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

portId string
portName string

Name of network port to be assigned to the VLAN

vlanId string
vlanVnid number

VXLAN Network Identifier, integer

device_id str

ID of device to be assigned to the VLAN

force_bond bool

Add port back to the bond when this resource is removed. Default is false.

native bool

Mark this VLAN a native VLAN on the port. This can be used only if this assignment assigns second or further VLAN to the port. To ensure that this attachment is not first on a port, you can use depends_on pointing to another packet_port_vlan_attachment, just like in the layer2-individual example above.

port_id str
port_name str

Name of network port to be assigned to the VLAN

vlan_id str
vlan_vnid int

VXLAN Network Identifier, integer

Package Details

Repository
https://github.com/pulumi/pulumi-packet
License
Apache-2.0
Notes
This Pulumi package is based on the packet Terraform Provider.