1. Packages
  2. Vsphere Provider
  3. API Docs
  4. Vnic
vSphere v4.13.1 published on Wednesday, Feb 5, 2025 by Pulumi

vsphere.Vnic

Explore with Pulumi AI

Provides a VMware vSphere vnic resource.

Example Usage

Create a vnic attached to a distributed virtual switch using the vmotion TCP/IP stack

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

const datacenter = vsphere.getDatacenter({
    name: "dc-01",
});
const host = datacenter.then(datacenter => vsphere.getHost({
    name: "esxi-01.example.com",
    datacenterId: datacenter.id,
}));
const vds = new vsphere.DistributedVirtualSwitch("vds", {
    name: "vds-01",
    datacenterId: datacenter.then(datacenter => datacenter.id),
    hosts: [{
        hostSystemId: host.then(host => host.id),
        devices: ["vnic3"],
    }],
});
const pg = new vsphere.DistributedPortGroup("pg", {
    name: "pg-01",
    vlanId: 1234,
    distributedVirtualSwitchUuid: vds.id,
});
const vnic = new vsphere.Vnic("vnic", {
    host: host.then(host => host.id),
    distributedSwitchPort: vds.id,
    distributedPortGroup: pg.id,
    ipv4: {
        dhcp: true,
    },
    netstack: "vmotion",
});
Copy
import pulumi
import pulumi_vsphere as vsphere

datacenter = vsphere.get_datacenter(name="dc-01")
host = vsphere.get_host(name="esxi-01.example.com",
    datacenter_id=datacenter.id)
vds = vsphere.DistributedVirtualSwitch("vds",
    name="vds-01",
    datacenter_id=datacenter.id,
    hosts=[{
        "host_system_id": host.id,
        "devices": ["vnic3"],
    }])
pg = vsphere.DistributedPortGroup("pg",
    name="pg-01",
    vlan_id=1234,
    distributed_virtual_switch_uuid=vds.id)
vnic = vsphere.Vnic("vnic",
    host=host.id,
    distributed_switch_port=vds.id,
    distributed_port_group=pg.id,
    ipv4={
        "dhcp": True,
    },
    netstack="vmotion")
Copy
package main

import (
	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
			Name: pulumi.StringRef("dc-01"),
		}, nil)
		if err != nil {
			return err
		}
		host, err := vsphere.LookupHost(ctx, &vsphere.LookupHostArgs{
			Name:         pulumi.StringRef("esxi-01.example.com"),
			DatacenterId: datacenter.Id,
		}, nil)
		if err != nil {
			return err
		}
		vds, err := vsphere.NewDistributedVirtualSwitch(ctx, "vds", &vsphere.DistributedVirtualSwitchArgs{
			Name:         pulumi.String("vds-01"),
			DatacenterId: pulumi.String(datacenter.Id),
			Hosts: vsphere.DistributedVirtualSwitchHostArray{
				&vsphere.DistributedVirtualSwitchHostArgs{
					HostSystemId: pulumi.String(host.Id),
					Devices: pulumi.StringArray{
						pulumi.String("vnic3"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		pg, err := vsphere.NewDistributedPortGroup(ctx, "pg", &vsphere.DistributedPortGroupArgs{
			Name:                         pulumi.String("pg-01"),
			VlanId:                       pulumi.Int(1234),
			DistributedVirtualSwitchUuid: vds.ID(),
		})
		if err != nil {
			return err
		}
		_, err = vsphere.NewVnic(ctx, "vnic", &vsphere.VnicArgs{
			Host:                  pulumi.String(host.Id),
			DistributedSwitchPort: vds.ID(),
			DistributedPortGroup:  pg.ID(),
			Ipv4: &vsphere.VnicIpv4Args{
				Dhcp: pulumi.Bool(true),
			},
			Netstack: pulumi.String("vmotion"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;

return await Deployment.RunAsync(() => 
{
    var datacenter = VSphere.GetDatacenter.Invoke(new()
    {
        Name = "dc-01",
    });

    var host = VSphere.GetHost.Invoke(new()
    {
        Name = "esxi-01.example.com",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });

    var vds = new VSphere.DistributedVirtualSwitch("vds", new()
    {
        Name = "vds-01",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
        Hosts = new[]
        {
            new VSphere.Inputs.DistributedVirtualSwitchHostArgs
            {
                HostSystemId = host.Apply(getHostResult => getHostResult.Id),
                Devices = new[]
                {
                    "vnic3",
                },
            },
        },
    });

    var pg = new VSphere.DistributedPortGroup("pg", new()
    {
        Name = "pg-01",
        VlanId = 1234,
        DistributedVirtualSwitchUuid = vds.Id,
    });

    var vnic = new VSphere.Vnic("vnic", new()
    {
        Host = host.Apply(getHostResult => getHostResult.Id),
        DistributedSwitchPort = vds.Id,
        DistributedPortGroup = pg.Id,
        Ipv4 = new VSphere.Inputs.VnicIpv4Args
        {
            Dhcp = true,
        },
        Netstack = "vmotion",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vsphere.VsphereFunctions;
import com.pulumi.vsphere.inputs.GetDatacenterArgs;
import com.pulumi.vsphere.inputs.GetHostArgs;
import com.pulumi.vsphere.DistributedVirtualSwitch;
import com.pulumi.vsphere.DistributedVirtualSwitchArgs;
import com.pulumi.vsphere.inputs.DistributedVirtualSwitchHostArgs;
import com.pulumi.vsphere.DistributedPortGroup;
import com.pulumi.vsphere.DistributedPortGroupArgs;
import com.pulumi.vsphere.Vnic;
import com.pulumi.vsphere.VnicArgs;
import com.pulumi.vsphere.inputs.VnicIpv4Args;
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) {
        final var datacenter = VsphereFunctions.getDatacenter(GetDatacenterArgs.builder()
            .name("dc-01")
            .build());

        final var host = VsphereFunctions.getHost(GetHostArgs.builder()
            .name("esxi-01.example.com")
            .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
            .build());

        var vds = new DistributedVirtualSwitch("vds", DistributedVirtualSwitchArgs.builder()
            .name("vds-01")
            .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
            .hosts(DistributedVirtualSwitchHostArgs.builder()
                .hostSystemId(host.applyValue(getHostResult -> getHostResult.id()))
                .devices("vnic3")
                .build())
            .build());

        var pg = new DistributedPortGroup("pg", DistributedPortGroupArgs.builder()
            .name("pg-01")
            .vlanId(1234)
            .distributedVirtualSwitchUuid(vds.id())
            .build());

        var vnic = new Vnic("vnic", VnicArgs.builder()
            .host(host.applyValue(getHostResult -> getHostResult.id()))
            .distributedSwitchPort(vds.id())
            .distributedPortGroup(pg.id())
            .ipv4(VnicIpv4Args.builder()
                .dhcp(true)
                .build())
            .netstack("vmotion")
            .build());

    }
}
Copy
resources:
  vds:
    type: vsphere:DistributedVirtualSwitch
    properties:
      name: vds-01
      datacenterId: ${datacenter.id}
      hosts:
        - hostSystemId: ${host.id}
          devices:
            - vnic3
  pg:
    type: vsphere:DistributedPortGroup
    properties:
      name: pg-01
      vlanId: 1234
      distributedVirtualSwitchUuid: ${vds.id}
  vnic:
    type: vsphere:Vnic
    properties:
      host: ${host.id}
      distributedSwitchPort: ${vds.id}
      distributedPortGroup: ${pg.id}
      ipv4:
        dhcp: true
      netstack: vmotion
variables:
  datacenter:
    fn::invoke:
      function: vsphere:getDatacenter
      arguments:
        name: dc-01
  host:
    fn::invoke:
      function: vsphere:getHost
      arguments:
        name: esxi-01.example.com
        datacenterId: ${datacenter.id}
Copy

Create a vnic attached to a portgroup using the default TCP/IP stack

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

const datacenter = vsphere.getDatacenter({
    name: "dc-01",
});
const host = datacenter.then(datacenter => vsphere.getHost({
    name: "esxi-01.example.com",
    datacenterId: datacenter.id,
}));
const hvs = new vsphere.HostVirtualSwitch("hvs", {
    name: "hvs-01",
    hostSystemId: host.then(host => host.id),
    networkAdapters: [
        "vmnic3",
        "vmnic4",
    ],
    activeNics: ["vmnic3"],
    standbyNics: ["vmnic4"],
});
const pg = new vsphere.HostPortGroup("pg", {
    name: "pg-01",
    virtualSwitchName: hvs.name,
    hostSystemId: host.then(host => host.id),
});
const vnic = new vsphere.Vnic("vnic", {
    host: host.then(host => host.id),
    portgroup: pg.name,
    ipv4: {
        dhcp: true,
    },
    services: [
        "vsan",
        "management",
    ],
});
Copy
import pulumi
import pulumi_vsphere as vsphere

datacenter = vsphere.get_datacenter(name="dc-01")
host = vsphere.get_host(name="esxi-01.example.com",
    datacenter_id=datacenter.id)
hvs = vsphere.HostVirtualSwitch("hvs",
    name="hvs-01",
    host_system_id=host.id,
    network_adapters=[
        "vmnic3",
        "vmnic4",
    ],
    active_nics=["vmnic3"],
    standby_nics=["vmnic4"])
pg = vsphere.HostPortGroup("pg",
    name="pg-01",
    virtual_switch_name=hvs.name,
    host_system_id=host.id)
vnic = vsphere.Vnic("vnic",
    host=host.id,
    portgroup=pg.name,
    ipv4={
        "dhcp": True,
    },
    services=[
        "vsan",
        "management",
    ])
Copy
package main

import (
	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
			Name: pulumi.StringRef("dc-01"),
		}, nil)
		if err != nil {
			return err
		}
		host, err := vsphere.LookupHost(ctx, &vsphere.LookupHostArgs{
			Name:         pulumi.StringRef("esxi-01.example.com"),
			DatacenterId: datacenter.Id,
		}, nil)
		if err != nil {
			return err
		}
		hvs, err := vsphere.NewHostVirtualSwitch(ctx, "hvs", &vsphere.HostVirtualSwitchArgs{
			Name:         pulumi.String("hvs-01"),
			HostSystemId: pulumi.String(host.Id),
			NetworkAdapters: pulumi.StringArray{
				pulumi.String("vmnic3"),
				pulumi.String("vmnic4"),
			},
			ActiveNics: pulumi.StringArray{
				pulumi.String("vmnic3"),
			},
			StandbyNics: pulumi.StringArray{
				pulumi.String("vmnic4"),
			},
		})
		if err != nil {
			return err
		}
		pg, err := vsphere.NewHostPortGroup(ctx, "pg", &vsphere.HostPortGroupArgs{
			Name:              pulumi.String("pg-01"),
			VirtualSwitchName: hvs.Name,
			HostSystemId:      pulumi.String(host.Id),
		})
		if err != nil {
			return err
		}
		_, err = vsphere.NewVnic(ctx, "vnic", &vsphere.VnicArgs{
			Host:      pulumi.String(host.Id),
			Portgroup: pg.Name,
			Ipv4: &vsphere.VnicIpv4Args{
				Dhcp: pulumi.Bool(true),
			},
			Services: pulumi.StringArray{
				pulumi.String("vsan"),
				pulumi.String("management"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;

return await Deployment.RunAsync(() => 
{
    var datacenter = VSphere.GetDatacenter.Invoke(new()
    {
        Name = "dc-01",
    });

    var host = VSphere.GetHost.Invoke(new()
    {
        Name = "esxi-01.example.com",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });

    var hvs = new VSphere.HostVirtualSwitch("hvs", new()
    {
        Name = "hvs-01",
        HostSystemId = host.Apply(getHostResult => getHostResult.Id),
        NetworkAdapters = new[]
        {
            "vmnic3",
            "vmnic4",
        },
        ActiveNics = new[]
        {
            "vmnic3",
        },
        StandbyNics = new[]
        {
            "vmnic4",
        },
    });

    var pg = new VSphere.HostPortGroup("pg", new()
    {
        Name = "pg-01",
        VirtualSwitchName = hvs.Name,
        HostSystemId = host.Apply(getHostResult => getHostResult.Id),
    });

    var vnic = new VSphere.Vnic("vnic", new()
    {
        Host = host.Apply(getHostResult => getHostResult.Id),
        Portgroup = pg.Name,
        Ipv4 = new VSphere.Inputs.VnicIpv4Args
        {
            Dhcp = true,
        },
        Services = new[]
        {
            "vsan",
            "management",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vsphere.VsphereFunctions;
import com.pulumi.vsphere.inputs.GetDatacenterArgs;
import com.pulumi.vsphere.inputs.GetHostArgs;
import com.pulumi.vsphere.HostVirtualSwitch;
import com.pulumi.vsphere.HostVirtualSwitchArgs;
import com.pulumi.vsphere.HostPortGroup;
import com.pulumi.vsphere.HostPortGroupArgs;
import com.pulumi.vsphere.Vnic;
import com.pulumi.vsphere.VnicArgs;
import com.pulumi.vsphere.inputs.VnicIpv4Args;
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) {
        final var datacenter = VsphereFunctions.getDatacenter(GetDatacenterArgs.builder()
            .name("dc-01")
            .build());

        final var host = VsphereFunctions.getHost(GetHostArgs.builder()
            .name("esxi-01.example.com")
            .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
            .build());

        var hvs = new HostVirtualSwitch("hvs", HostVirtualSwitchArgs.builder()
            .name("hvs-01")
            .hostSystemId(host.applyValue(getHostResult -> getHostResult.id()))
            .networkAdapters(            
                "vmnic3",
                "vmnic4")
            .activeNics("vmnic3")
            .standbyNics("vmnic4")
            .build());

        var pg = new HostPortGroup("pg", HostPortGroupArgs.builder()
            .name("pg-01")
            .virtualSwitchName(hvs.name())
            .hostSystemId(host.applyValue(getHostResult -> getHostResult.id()))
            .build());

        var vnic = new Vnic("vnic", VnicArgs.builder()
            .host(host.applyValue(getHostResult -> getHostResult.id()))
            .portgroup(pg.name())
            .ipv4(VnicIpv4Args.builder()
                .dhcp(true)
                .build())
            .services(            
                "vsan",
                "management")
            .build());

    }
}
Copy
resources:
  hvs:
    type: vsphere:HostVirtualSwitch
    properties:
      name: hvs-01
      hostSystemId: ${host.id}
      networkAdapters:
        - vmnic3
        - vmnic4
      activeNics:
        - vmnic3
      standbyNics:
        - vmnic4
  pg:
    type: vsphere:HostPortGroup
    properties:
      name: pg-01
      virtualSwitchName: ${hvs.name}
      hostSystemId: ${host.id}
  vnic:
    type: vsphere:Vnic
    properties:
      host: ${host.id}
      portgroup: ${pg.name}
      ipv4:
        dhcp: true
      services:
        - vsan
        - management
variables:
  datacenter:
    fn::invoke:
      function: vsphere:getDatacenter
      arguments:
        name: dc-01
  host:
    fn::invoke:
      function: vsphere:getHost
      arguments:
        name: esxi-01.example.com
        datacenterId: ${datacenter.id}
Copy

Create Vnic Resource

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

Constructor syntax

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

@overload
def Vnic(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         host: Optional[str] = None,
         distributed_port_group: Optional[str] = None,
         distributed_switch_port: Optional[str] = None,
         ipv4: Optional[VnicIpv4Args] = None,
         ipv6: Optional[VnicIpv6Args] = None,
         mac: Optional[str] = None,
         mtu: Optional[int] = None,
         netstack: Optional[str] = None,
         portgroup: Optional[str] = None,
         services: Optional[Sequence[str]] = None)
func NewVnic(ctx *Context, name string, args VnicArgs, opts ...ResourceOption) (*Vnic, error)
public Vnic(string name, VnicArgs args, CustomResourceOptions? opts = null)
public Vnic(String name, VnicArgs args)
public Vnic(String name, VnicArgs args, CustomResourceOptions options)
type: vsphere:Vnic
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. VnicArgs
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. VnicArgs
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. VnicArgs
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. VnicArgs
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. VnicArgs
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 vnicResource = new VSphere.Vnic("vnicResource", new()
{
    Host = "string",
    DistributedPortGroup = "string",
    DistributedSwitchPort = "string",
    Ipv4 = new VSphere.Inputs.VnicIpv4Args
    {
        Dhcp = false,
        Gw = "string",
        Ip = "string",
        Netmask = "string",
    },
    Ipv6 = new VSphere.Inputs.VnicIpv6Args
    {
        Addresses = new[]
        {
            "string",
        },
        Autoconfig = false,
        Dhcp = false,
        Gw = "string",
    },
    Mac = "string",
    Mtu = 0,
    Netstack = "string",
    Portgroup = "string",
    Services = new[]
    {
        "string",
    },
});
Copy
example, err := vsphere.NewVnic(ctx, "vnicResource", &vsphere.VnicArgs{
	Host:                  pulumi.String("string"),
	DistributedPortGroup:  pulumi.String("string"),
	DistributedSwitchPort: pulumi.String("string"),
	Ipv4: &vsphere.VnicIpv4Args{
		Dhcp:    pulumi.Bool(false),
		Gw:      pulumi.String("string"),
		Ip:      pulumi.String("string"),
		Netmask: pulumi.String("string"),
	},
	Ipv6: &vsphere.VnicIpv6Args{
		Addresses: pulumi.StringArray{
			pulumi.String("string"),
		},
		Autoconfig: pulumi.Bool(false),
		Dhcp:       pulumi.Bool(false),
		Gw:         pulumi.String("string"),
	},
	Mac:       pulumi.String("string"),
	Mtu:       pulumi.Int(0),
	Netstack:  pulumi.String("string"),
	Portgroup: pulumi.String("string"),
	Services: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var vnicResource = new Vnic("vnicResource", VnicArgs.builder()
    .host("string")
    .distributedPortGroup("string")
    .distributedSwitchPort("string")
    .ipv4(VnicIpv4Args.builder()
        .dhcp(false)
        .gw("string")
        .ip("string")
        .netmask("string")
        .build())
    .ipv6(VnicIpv6Args.builder()
        .addresses("string")
        .autoconfig(false)
        .dhcp(false)
        .gw("string")
        .build())
    .mac("string")
    .mtu(0)
    .netstack("string")
    .portgroup("string")
    .services("string")
    .build());
Copy
vnic_resource = vsphere.Vnic("vnicResource",
    host="string",
    distributed_port_group="string",
    distributed_switch_port="string",
    ipv4={
        "dhcp": False,
        "gw": "string",
        "ip": "string",
        "netmask": "string",
    },
    ipv6={
        "addresses": ["string"],
        "autoconfig": False,
        "dhcp": False,
        "gw": "string",
    },
    mac="string",
    mtu=0,
    netstack="string",
    portgroup="string",
    services=["string"])
Copy
const vnicResource = new vsphere.Vnic("vnicResource", {
    host: "string",
    distributedPortGroup: "string",
    distributedSwitchPort: "string",
    ipv4: {
        dhcp: false,
        gw: "string",
        ip: "string",
        netmask: "string",
    },
    ipv6: {
        addresses: ["string"],
        autoconfig: false,
        dhcp: false,
        gw: "string",
    },
    mac: "string",
    mtu: 0,
    netstack: "string",
    portgroup: "string",
    services: ["string"],
});
Copy
type: vsphere:Vnic
properties:
    distributedPortGroup: string
    distributedSwitchPort: string
    host: string
    ipv4:
        dhcp: false
        gw: string
        ip: string
        netmask: string
    ipv6:
        addresses:
            - string
        autoconfig: false
        dhcp: false
        gw: string
    mac: string
    mtu: 0
    netstack: string
    portgroup: string
    services:
        - string
Copy

Vnic 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 Vnic resource accepts the following input properties:

Host
This property is required.
Changes to this property will trigger replacement.
string
ESX host the interface belongs to
DistributedPortGroup string
Key of the distributed portgroup the nic will connect to.
DistributedSwitchPort string
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
Ipv4 Pulumi.VSphere.Inputs.VnicIpv4
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
Ipv6 Pulumi.VSphere.Inputs.VnicIpv6
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
Mac string
MAC address of the interface.
Mtu int
MTU of the interface.
Netstack Changes to this property will trigger replacement. string
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
Portgroup string
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
Services List<string>
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
Host
This property is required.
Changes to this property will trigger replacement.
string
ESX host the interface belongs to
DistributedPortGroup string
Key of the distributed portgroup the nic will connect to.
DistributedSwitchPort string
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
Ipv4 VnicIpv4Args
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
Ipv6 VnicIpv6Args
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
Mac string
MAC address of the interface.
Mtu int
MTU of the interface.
Netstack Changes to this property will trigger replacement. string
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
Portgroup string
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
Services []string
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
host
This property is required.
Changes to this property will trigger replacement.
String
ESX host the interface belongs to
distributedPortGroup String
Key of the distributed portgroup the nic will connect to.
distributedSwitchPort String
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
ipv4 VnicIpv4
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 VnicIpv6
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac String
MAC address of the interface.
mtu Integer
MTU of the interface.
netstack Changes to this property will trigger replacement. String
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup String
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services List<String>
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
host
This property is required.
Changes to this property will trigger replacement.
string
ESX host the interface belongs to
distributedPortGroup string
Key of the distributed portgroup the nic will connect to.
distributedSwitchPort string
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
ipv4 VnicIpv4
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 VnicIpv6
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac string
MAC address of the interface.
mtu number
MTU of the interface.
netstack Changes to this property will trigger replacement. string
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup string
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services string[]
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
host
This property is required.
Changes to this property will trigger replacement.
str
ESX host the interface belongs to
distributed_port_group str
Key of the distributed portgroup the nic will connect to.
distributed_switch_port str
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
ipv4 VnicIpv4Args
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 VnicIpv6Args
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac str
MAC address of the interface.
mtu int
MTU of the interface.
netstack Changes to this property will trigger replacement. str
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup str
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services Sequence[str]
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
host
This property is required.
Changes to this property will trigger replacement.
String
ESX host the interface belongs to
distributedPortGroup String
Key of the distributed portgroup the nic will connect to.
distributedSwitchPort String
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
ipv4 Property Map
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 Property Map
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac String
MAC address of the interface.
mtu Number
MTU of the interface.
netstack Changes to this property will trigger replacement. String
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup String
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services List<String>
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.

Outputs

All input properties are implicitly available as output properties. Additionally, the Vnic 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 Vnic Resource

Get an existing Vnic 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?: VnicState, opts?: CustomResourceOptions): Vnic
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        distributed_port_group: Optional[str] = None,
        distributed_switch_port: Optional[str] = None,
        host: Optional[str] = None,
        ipv4: Optional[VnicIpv4Args] = None,
        ipv6: Optional[VnicIpv6Args] = None,
        mac: Optional[str] = None,
        mtu: Optional[int] = None,
        netstack: Optional[str] = None,
        portgroup: Optional[str] = None,
        services: Optional[Sequence[str]] = None) -> Vnic
func GetVnic(ctx *Context, name string, id IDInput, state *VnicState, opts ...ResourceOption) (*Vnic, error)
public static Vnic Get(string name, Input<string> id, VnicState? state, CustomResourceOptions? opts = null)
public static Vnic get(String name, Output<String> id, VnicState state, CustomResourceOptions options)
resources:  _:    type: vsphere:Vnic    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:
DistributedPortGroup string
Key of the distributed portgroup the nic will connect to.
DistributedSwitchPort string
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
Host Changes to this property will trigger replacement. string
ESX host the interface belongs to
Ipv4 Pulumi.VSphere.Inputs.VnicIpv4
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
Ipv6 Pulumi.VSphere.Inputs.VnicIpv6
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
Mac string
MAC address of the interface.
Mtu int
MTU of the interface.
Netstack Changes to this property will trigger replacement. string
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
Portgroup string
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
Services List<string>
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
DistributedPortGroup string
Key of the distributed portgroup the nic will connect to.
DistributedSwitchPort string
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
Host Changes to this property will trigger replacement. string
ESX host the interface belongs to
Ipv4 VnicIpv4Args
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
Ipv6 VnicIpv6Args
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
Mac string
MAC address of the interface.
Mtu int
MTU of the interface.
Netstack Changes to this property will trigger replacement. string
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
Portgroup string
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
Services []string
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
distributedPortGroup String
Key of the distributed portgroup the nic will connect to.
distributedSwitchPort String
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
host Changes to this property will trigger replacement. String
ESX host the interface belongs to
ipv4 VnicIpv4
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 VnicIpv6
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac String
MAC address of the interface.
mtu Integer
MTU of the interface.
netstack Changes to this property will trigger replacement. String
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup String
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services List<String>
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
distributedPortGroup string
Key of the distributed portgroup the nic will connect to.
distributedSwitchPort string
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
host Changes to this property will trigger replacement. string
ESX host the interface belongs to
ipv4 VnicIpv4
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 VnicIpv6
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac string
MAC address of the interface.
mtu number
MTU of the interface.
netstack Changes to this property will trigger replacement. string
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup string
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services string[]
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
distributed_port_group str
Key of the distributed portgroup the nic will connect to.
distributed_switch_port str
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
host Changes to this property will trigger replacement. str
ESX host the interface belongs to
ipv4 VnicIpv4Args
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 VnicIpv6Args
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac str
MAC address of the interface.
mtu int
MTU of the interface.
netstack Changes to this property will trigger replacement. str
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup str
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services Sequence[str]
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.
distributedPortGroup String
Key of the distributed portgroup the nic will connect to.
distributedSwitchPort String
UUID of the vdswitch the nic will be attached to. Do not set if you set portgroup.
host Changes to this property will trigger replacement. String
ESX host the interface belongs to
ipv4 Property Map
IPv4 settings. Either this or ipv6 needs to be set. See IPv4 options below.
ipv6 Property Map
IPv6 settings. Either this or ipv6 needs to be set. See IPv6 options below.
mac String
MAC address of the interface.
mtu Number
MTU of the interface.
netstack Changes to this property will trigger replacement. String
TCP/IP stack setting for this interface. Possible values are defaultTcpipStack``, 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default:defaultTcpipStack`)
portgroup String
Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
services List<String>
Enabled services setting for this interface. Currently support values are vmotion, management, and vsan.

Supporting Types

VnicIpv4
, VnicIpv4Args

Dhcp bool
Use DHCP to configure the interface's IPv4 stack.
Gw string
IP address of the default gateway, if DHCP is not set.
Ip string
address of the interface, if DHCP is not set.
Netmask string
netmask of the interface, if DHCP is not set.
Dhcp bool
Use DHCP to configure the interface's IPv4 stack.
Gw string
IP address of the default gateway, if DHCP is not set.
Ip string
address of the interface, if DHCP is not set.
Netmask string
netmask of the interface, if DHCP is not set.
dhcp Boolean
Use DHCP to configure the interface's IPv4 stack.
gw String
IP address of the default gateway, if DHCP is not set.
ip String
address of the interface, if DHCP is not set.
netmask String
netmask of the interface, if DHCP is not set.
dhcp boolean
Use DHCP to configure the interface's IPv4 stack.
gw string
IP address of the default gateway, if DHCP is not set.
ip string
address of the interface, if DHCP is not set.
netmask string
netmask of the interface, if DHCP is not set.
dhcp bool
Use DHCP to configure the interface's IPv4 stack.
gw str
IP address of the default gateway, if DHCP is not set.
ip str
address of the interface, if DHCP is not set.
netmask str
netmask of the interface, if DHCP is not set.
dhcp Boolean
Use DHCP to configure the interface's IPv4 stack.
gw String
IP address of the default gateway, if DHCP is not set.
ip String
address of the interface, if DHCP is not set.
netmask String
netmask of the interface, if DHCP is not set.

VnicIpv6
, VnicIpv6Args

Addresses List<string>
List of IPv6 addresses
Autoconfig bool
Use IPv6 Autoconfiguration (RFC2462).
Dhcp bool
Use DHCP to configure the interface's IPv4 stack.
Gw string
IP address of the default gateway, if DHCP or autoconfig is not set.
Addresses []string
List of IPv6 addresses
Autoconfig bool
Use IPv6 Autoconfiguration (RFC2462).
Dhcp bool
Use DHCP to configure the interface's IPv4 stack.
Gw string
IP address of the default gateway, if DHCP or autoconfig is not set.
addresses List<String>
List of IPv6 addresses
autoconfig Boolean
Use IPv6 Autoconfiguration (RFC2462).
dhcp Boolean
Use DHCP to configure the interface's IPv4 stack.
gw String
IP address of the default gateway, if DHCP or autoconfig is not set.
addresses string[]
List of IPv6 addresses
autoconfig boolean
Use IPv6 Autoconfiguration (RFC2462).
dhcp boolean
Use DHCP to configure the interface's IPv4 stack.
gw string
IP address of the default gateway, if DHCP or autoconfig is not set.
addresses Sequence[str]
List of IPv6 addresses
autoconfig bool
Use IPv6 Autoconfiguration (RFC2462).
dhcp bool
Use DHCP to configure the interface's IPv4 stack.
gw str
IP address of the default gateway, if DHCP or autoconfig is not set.
addresses List<String>
List of IPv6 addresses
autoconfig Boolean
Use IPv6 Autoconfiguration (RFC2462).
dhcp Boolean
Use DHCP to configure the interface's IPv4 stack.
gw String
IP address of the default gateway, if DHCP or autoconfig is not set.

Import

An existing vNic can be imported into this resource

via supplying the vNic’s ID. An example is below:

$ pulumi import vsphere:index/vnic:Vnic vnic host-123_vmk2
Copy

The above would import the vnic vmk2 from host with ID host-123.

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

Package Details

Repository
vSphere pulumi/pulumi-vsphere
License
Apache-2.0
Notes
This Pulumi package is based on the vsphere Terraform Provider.