Show / Hide Table of Contents

Namespace Pulumi.VSphere

Classes

ComputeCluster

A note on the naming of this resource: VMware refers to clusters of hosts in the UI and documentation as clusters, HA clusters, or DRS clusters. All of these refer to the same kind of resource (with the latter two referring to specific features of clustering). We use vsphere..ComputeCluster to differentiate host clusters from datastore clusters, which are clusters of datastores that can be used to distribute load and ensure fault tolerance via distribution of virtual machines. Datastore clusters can also be managed through the provider, via the vsphere..DatastoreCluster resource.

The vsphere..ComputeCluster resource can be used to create and manage clusters of hosts allowing for resource control of compute resources, load balancing through DRS, and high availability through vSphere HA.

For more information on vSphere clusters and DRS, see this page. For more information on vSphere HA, see this page.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

vSphere Version Requirements

A large number of settings in the vsphere..ComputeCluster resource require a specific version of vSphere to function. Rather than include warnings at every setting or section, these settings are documented below. Note that this list is for cluster-specific attributes only, and does not include the tags parameter, which requires vSphere 6.0 or higher across all resources that can be tagged.

All settings are footnoted by an asterisk (*) in their specific section in the documentation, which takes you here.

Settings that require vSphere version 6.0 or higher

These settings require vSphere 6.0 or higher:

  • ha_datastore_apd_recovery_action
  • ha_datastore_apd_response
  • ha_datastore_apd_response_delay
  • ha_datastore_pdl_response
  • ha_vm_component_protection

Settings that require vSphere version 6.5 or higher

These settings require vSphere 6.5 or higher:

  • drs_enable_predictive_drs
  • ha_admission_control_host_failure_tolerance (When ha_admission_control_policy is set to resourcePercentage or slotPolicy. Permitted in all versions under failoverHosts)
  • ha_admission_control_resource_percentage_auto_compute
  • ha_vm_restart_timeout
  • ha_vm_dependency_restart_condition
  • ha_vm_restart_additional_delay
  • proactive_ha_automation_level
  • proactive_ha_enabled
  • proactive_ha_moderate_remediation
  • proactive_ha_provider_ids
  • proactive_ha_severe_remediation

ComputeClusterArgs

ComputeClusterHostGroup

The vsphere..ComputeClusterHostGroup resource can be used to manage groups of hosts in a cluster, either created by the vsphere..ComputeCluster resource or looked up by the vsphere..ComputeCluster data source.

This resource mainly serves as an input to the vsphere..ComputeClusterVmHostRule resource - see the documentation for that resource for further details on how to use host groups.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

ComputeClusterHostGroupArgs

ComputeClusterHostGroupState

ComputeClusterState

ComputeClusterVmAffinityRule

The vsphere..ComputeClusterVmAffinityRule resource can be used to manage VM affinity rules in a cluster, either created by the vsphere..ComputeCluster resource or looked up by the vsphere..ComputeCluster data source.

This rule can be used to tell a set to virtual machines to run together on a single host within a cluster. When configured, DRS will make a best effort to ensure that the virtual machines run on the same host, or prevent any operation that would keep that from happening, depending on the value of the mandatory flag.

Keep in mind that this rule can only be used to tell VMs to run together on a non-specific host - it can't be used to pin VMs to a host. For that, see the vsphere..ComputeClusterVmHostRule resource.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm = new List<VSphere.VirtualMachine>();
    for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        vm.Add(new VSphere.VirtualMachine($"vm-{range.Value}", new VSphere.VirtualMachineArgs
        {
            DatastoreId = datastore.Apply(datastore => datastore.Id),
            Disks = 
            {
                new VSphere.Inputs.VirtualMachineDiskArgs
                {
                    Label = "disk0",
                    Size = 20,
                },
            },
            GuestId = "other3xLinux64Guest",
            Memory = 2048,
            NetworkInterfaces = 
            {
                new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
                {
                    NetworkId = network.Apply(network => network.Id),
                },
            },
            NumCpus = 2,
            ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
        }));
    }
    var clusterVmAffinityRule = new VSphere.ComputeClusterVmAffinityRule("clusterVmAffinityRule", new VSphere.ComputeClusterVmAffinityRuleArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VirtualMachineIds = vm.Select(__item => __item.Id).ToList(),
    });
}

}

ComputeClusterVmAffinityRuleArgs

ComputeClusterVmAffinityRuleState

ComputeClusterVmAntiAffinityRule

The vsphere..ComputeClusterVmAntiAffinityRule resource can be used to manage VM anti-affinity rules in a cluster, either created by the vsphere..ComputeCluster resource or looked up by the vsphere..ComputeCluster data source.

This rule can be used to tell a set to virtual machines to run on different hosts within a cluster, useful for preventing single points of failure in application cluster scenarios. When configured, DRS will make a best effort to ensure that the virtual machines run on different hosts, or prevent any operation that would keep that from happening, depending on the value of the mandatory flag.

Keep in mind that this rule can only be used to tell VMs to run separately on non-specific hosts - specific hosts cannot be specified with this rule. For that, see the vsphere..ComputeClusterVmHostRule resource.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm = new List<VSphere.VirtualMachine>();
    for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        vm.Add(new VSphere.VirtualMachine($"vm-{range.Value}", new VSphere.VirtualMachineArgs
        {
            DatastoreId = datastore.Apply(datastore => datastore.Id),
            Disks = 
            {
                new VSphere.Inputs.VirtualMachineDiskArgs
                {
                    Label = "disk0",
                    Size = 20,
                },
            },
            GuestId = "other3xLinux64Guest",
            Memory = 2048,
            NetworkInterfaces = 
            {
                new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
                {
                    NetworkId = network.Apply(network => network.Id),
                },
            },
            NumCpus = 2,
            ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
        }));
    }
    var clusterVmAntiAffinityRule = new VSphere.ComputeClusterVmAntiAffinityRule("clusterVmAntiAffinityRule", new VSphere.ComputeClusterVmAntiAffinityRuleArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VirtualMachineIds = vm.Select(__item => __item.Id).ToList(),
    });
}

}

ComputeClusterVmAntiAffinityRuleArgs

ComputeClusterVmAntiAffinityRuleState

ComputeClusterVmDependencyRule

The vsphere..ComputeClusterVmDependencyRule resource can be used to manage VM dependency rules in a cluster, either created by the vsphere..ComputeCluster resource or looked up by the vsphere..ComputeCluster data source.

A virtual machine dependency rule applies to vSphere HA, and allows user-defined startup orders for virtual machines in the case of host failure. Virtual machines are supplied via groups, which can be managed via the vsphere..ComputeClusterVmGroup resource.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm1 = new VSphere.VirtualMachine("vm1", new VSphere.VirtualMachineArgs
    {
        DatastoreId = datastore.Apply(datastore => datastore.Id),
        Disks = 
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 20,
            },
        },
        GuestId = "other3xLinux64Guest",
        Memory = 2048,
        NetworkInterfaces = 
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(network => network.Id),
            },
        },
        NumCpus = 2,
        ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
    });
    var vm2 = new VSphere.VirtualMachine("vm2", new VSphere.VirtualMachineArgs
    {
        DatastoreId = datastore.Apply(datastore => datastore.Id),
        Disks = 
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 20,
            },
        },
        GuestId = "other3xLinux64Guest",
        Memory = 2048,
        NetworkInterfaces = 
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(network => network.Id),
            },
        },
        NumCpus = 2,
        ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
    });
    var clusterVmGroup1 = new VSphere.ComputeClusterVmGroup("clusterVmGroup1", new VSphere.ComputeClusterVmGroupArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VirtualMachineIds = 
        {
            vm1.Id,
        },
    });
    var clusterVmGroup2 = new VSphere.ComputeClusterVmGroup("clusterVmGroup2", new VSphere.ComputeClusterVmGroupArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VirtualMachineIds = 
        {
            vm2.Id,
        },
    });
    var clusterVmDependencyRule = new VSphere.ComputeClusterVmDependencyRule("clusterVmDependencyRule", new VSphere.ComputeClusterVmDependencyRuleArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        DependencyVmGroupName = clusterVmGroup1.Name,
        VmGroupName = clusterVmGroup2.Name,
    });
}

}

ComputeClusterVmDependencyRuleArgs

ComputeClusterVmDependencyRuleState

ComputeClusterVmGroup

The vsphere..ComputeClusterVmGroup resource can be used to manage groups of virtual machines in a cluster, either created by the vsphere..ComputeCluster resource or looked up by the vsphere..ComputeCluster data source.

This resource mainly serves as an input to the vsphere..ComputeClusterVmDependencyRule and vsphere..ComputeClusterVmHostRule resources. See the individual resource documentation pages for more information.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm = new List<VSphere.VirtualMachine>();
    for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        vm.Add(new VSphere.VirtualMachine($"vm-{range.Value}", new VSphere.VirtualMachineArgs
        {
            DatastoreId = datastore.Apply(datastore => datastore.Id),
            Disks = 
            {
                new VSphere.Inputs.VirtualMachineDiskArgs
                {
                    Label = "disk0",
                    Size = 20,
                },
            },
            GuestId = "other3xLinux64Guest",
            Memory = 2048,
            NetworkInterfaces = 
            {
                new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
                {
                    NetworkId = network.Apply(network => network.Id),
                },
            },
            NumCpus = 2,
            ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
        }));
    }
    var clusterVmGroup = new VSphere.ComputeClusterVmGroup("clusterVmGroup", new VSphere.ComputeClusterVmGroupArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VirtualMachineIds = vm.Select(__item => __item.Id).ToList(),
    });
}

}

ComputeClusterVmGroupArgs

ComputeClusterVmGroupState

ComputeClusterVmHostRule

The vsphere..ComputeClusterVmHostRule resource can be used to manage VM-to-host rules in a cluster, either created by the vsphere..ComputeCluster resource or looked up by the vsphere..ComputeCluster data source.

This resource can create both affinity rules, where virtual machines run on specified hosts, or anti-affinity rules, where virtual machines run on hosts outside of the ones specified in the rule. Virtual machines and hosts are supplied via groups, which can be managed via the vsphere..ComputeClusterVmGroup and vsphere..ComputeClusterHostGroup resources.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var host = dc.Apply(dc => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
    {
        DatacenterId = dc.Id,
        Name = "esxi1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm = new VSphere.VirtualMachine("vm", new VSphere.VirtualMachineArgs
    {
        DatastoreId = datastore.Apply(datastore => datastore.Id),
        Disks = 
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 20,
            },
        },
        GuestId = "other3xLinux64Guest",
        Memory = 2048,
        NetworkInterfaces = 
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(network => network.Id),
            },
        },
        NumCpus = 2,
        ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
    });
    var clusterVmGroup = new VSphere.ComputeClusterVmGroup("clusterVmGroup", new VSphere.ComputeClusterVmGroupArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VirtualMachineIds = 
        {
            vm.Id,
        },
    });
    var clusterHostGroup = new VSphere.ComputeClusterHostGroup("clusterHostGroup", new VSphere.ComputeClusterHostGroupArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        HostSystemIds = 
        {
            host.Apply(host => host.Id),
        },
    });
    var clusterVmHostRule = new VSphere.ComputeClusterVmHostRule("clusterVmHostRule", new VSphere.ComputeClusterVmHostRuleArgs
    {
        AffinityHostGroupName = clusterHostGroup.Name,
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        VmGroupName = clusterVmGroup.Name,
    });
}

}

ComputeClusterVmHostRuleArgs

ComputeClusterVmHostRuleState

Config

ContentLibrary

ContentLibraryArgs

ContentLibraryItem

ContentLibraryItemArgs

ContentLibraryItemState

ContentLibraryState

CustomAttribute

CustomAttributeArgs

CustomAttributeState

Datacenter

Provides a VMware vSphere datacenter resource. This can be used as the primary container of inventory objects such as hosts and virtual machines.

Example Usage

Create datacenter on the root folder

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var prodDatacenter = new VSphere.Datacenter("prodDatacenter", new VSphere.DatacenterArgs
    {
    });
}

}

Create datacenter on a subfolder

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var researchDatacenter = new VSphere.Datacenter("researchDatacenter", new VSphere.DatacenterArgs
    {
        Folder = "/research/",
    });
}

}

DatacenterArgs

DatacenterState

DatastoreCluster

The vsphere..DatastoreCluster resource can be used to create and manage datastore clusters. This can be used to create groups of datastores with a shared management interface, allowing for resource control and load balancing through Storage DRS.

For more information on vSphere datastore clusters and Storage DRS, see this page.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: Storage DRS requires a vSphere Enterprise Plus license.

DatastoreClusterArgs

DatastoreClusterState

DatastoreClusterVmAntiAffinityRule

The vsphere..DatastoreClusterVmAntiAffinityRule resource can be used to manage VM anti-affinity rules in a datastore cluster, either created by the vsphere..DatastoreCluster resource or looked up by the vsphere..DatastoreCluster data source.

This rule can be used to tell a set to virtual machines to run on different datastores within a cluster, useful for preventing single points of failure in application cluster scenarios. When configured, Storage DRS will make a best effort to ensure that the virtual machines run on different datastores, or prevent any operation that would keep that from happening, depending on the value of the mandatory flag.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: Storage DRS requires a vSphere Enterprise Plus license.

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastoreCluster = dc.Apply(dc => Output.Create(VSphere.GetDatastoreCluster.InvokeAsync(new VSphere.GetDatastoreClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore-cluster1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm = new List<VSphere.VirtualMachine>();
    for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        vm.Add(new VSphere.VirtualMachine($"vm-{range.Value}", new VSphere.VirtualMachineArgs
        {
            DatastoreClusterId = datastoreCluster.Apply(datastoreCluster => datastoreCluster.Id),
            Disks = 
            {
                new VSphere.Inputs.VirtualMachineDiskArgs
                {
                    Label = "disk0",
                    Size = 20,
                },
            },
            GuestId = "other3xLinux64Guest",
            Memory = 2048,
            NetworkInterfaces = 
            {
                new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
                {
                    NetworkId = network.Apply(network => network.Id),
                },
            },
            NumCpus = 2,
            ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
        }));
    }
    var clusterVmAntiAffinityRule = new VSphere.DatastoreClusterVmAntiAffinityRule("clusterVmAntiAffinityRule", new VSphere.DatastoreClusterVmAntiAffinityRuleArgs
    {
        DatastoreClusterId = datastoreCluster.Apply(datastoreCluster => datastoreCluster.Id),
        VirtualMachineIds = vm.Select(__item => __item.Id).ToList(),
    });
}

}

DatastoreClusterVmAntiAffinityRuleArgs

DatastoreClusterVmAntiAffinityRuleState

DistributedPortGroup

The vsphere..DistributedPortGroup resource can be used to manage vSphere distributed virtual port groups. These port groups are connected to distributed virtual switches, which can be managed by the vsphere..DistributedVirtualSwitch resource.

Distributed port groups can be used as networks for virtual machines, allowing VMs to use the networking supplied by a distributed virtual switch (DVS), with a set of policies that apply to that individual newtork, if desired.

For an overview on vSphere networking concepts, see this page. For more information on vSphere DVS portgroups, see this page.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

Example Usage

Overriding DVS policies

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dvs = new VSphere.DistributedVirtualSwitch("dvs", new VSphere.DistributedVirtualSwitchArgs
    {
        ActiveUplinks = 
        {
            "tfup1",
        },
        DatacenterId = data.Vsphere_datacenter.Dc.Id,
        StandbyUplinks = 
        {
            "tfup2",
        },
        Uplinks = 
        {
            "tfup1",
            "tfup2",
        },
    });
    var pg = new VSphere.DistributedPortGroup("pg", new VSphere.DistributedPortGroupArgs
    {
        ActiveUplinks = 
        {
            "tfup1",
            "tfup2",
        },
        DistributedVirtualSwitchUuid = dvs.Id,
        StandbyUplinks = {},
        VlanId = 1000,
    });
}

}

DistributedPortGroupArgs

DistributedPortGroupState

DistributedVirtualSwitch

The vsphere..DistributedVirtualSwitch resource can be used to manage VMware Distributed Virtual Switches.

An essential component of a distributed, scalable VMware datacenter, the vSphere Distributed Virtual Switch (DVS) provides centralized management and monitoring of the networking configuration of all the hosts that are associated with the switch. In addition to adding port groups (see the vsphere..DistributedPortGroup resource) that can be used as networks for virtual machines, a DVS can be configured to perform advanced high availability, traffic shaping, network monitoring, and more.

For an overview on vSphere networking concepts, see this page. For more information on vSphere DVS, see this page.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

Example Usage

Uplink name and count control

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dvs = new VSphere.DistributedVirtualSwitch("dvs", new VSphere.DistributedVirtualSwitchArgs
    {
        ActiveUplinks = 
        {
            "tfup1",
        },
        DatacenterId = data.Vsphere_datacenter.Dc.Id,
        StandbyUplinks = 
        {
            "tfup2",
        },
        Uplinks = 
        {
            "tfup1",
            "tfup2",
        },
    });
}

}

DistributedVirtualSwitchArgs

DistributedVirtualSwitchState

DpmHostOverride

The vsphere..DpmHostOverride resource can be used to add a DPM override to a cluster for a particular host. This allows you to control the power management settings for individual hosts in the cluster while leaving any unspecified ones at the default power management settings.

For more information on DPM within vSphere clusters, see this page.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

DpmHostOverrideArgs

DpmHostOverrideState

DrsVmOverride

The vsphere..DrsVmOverride resource can be used to add a DRS override to a cluster for a specific virtual machine. With this resource, one can enable or disable DRS and control the automation level for a single virtual machine without affecting the rest of the cluster.

For more information on vSphere clusters and DRS, see this page.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

NOTE: vSphere DRS requires a vSphere Enterprise Plus license.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var host = dc.Apply(dc => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
    {
        DatacenterId = dc.Id,
        Name = "esxi1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm = new VSphere.VirtualMachine("vm", new VSphere.VirtualMachineArgs
    {
        DatastoreId = datastore.Apply(datastore => datastore.Id),
        Disks = 
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 20,
            },
        },
        GuestId = "other3xLinux64Guest",
        HostSystemId = host.Apply(host => host.Id),
        Memory = 2048,
        NetworkInterfaces = 
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(network => network.Id),
            },
        },
        NumCpus = 2,
        ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
    });
    var drsVmOverride = new VSphere.DrsVmOverride("drsVmOverride", new VSphere.DrsVmOverrideArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        DrsEnabled = false,
        VirtualMachineId = vm.Id,
    });
}

}

DrsVmOverrideArgs

DrsVmOverrideState

File

The vsphere..File resource can be used to upload files (such as virtual disk files) from the host machine that this provider is running on to a target datastore. The resource can also be used to copy files between datastores, or from one location to another on the same datastore.

Updates to destination parameters such as datacenter, datastore, or destination_file will move the managed file a new destination based on the values of the new settings. If any source parameter is changed, such as source_datastore, source_datacenter or source_file), the resource will be re-created. Depending on if destination parameters are being changed as well, this may result in the destination file either being overwritten or deleted at the old location.

Example Usage

Uploading a file

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var ubuntuDiskUpload = new VSphere.File("ubuntuDiskUpload", new VSphere.FileArgs
    {
        Datacenter = "my_datacenter",
        Datastore = "local",
        DestinationFile = "/my_path/disks/custom_ubuntu.vmdk",
        SourceFile = "/home/ubuntu/my_disks/custom_ubuntu.vmdk",
    });
}

}

Copying a file

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var ubuntuDiskCopy = new VSphere.File("ubuntuDiskCopy", new VSphere.FileArgs
    {
        Datacenter = "my_datacenter",
        Datastore = "local",
        DestinationFile = "/my_path/custom_ubuntu_id.vmdk",
        SourceDatacenter = "my_datacenter",
        SourceDatastore = "local",
        SourceFile = "/my_path/disks/custom_ubuntu.vmdk",
    });
}

}

FileArgs

FileState

Folder

The vsphere..Folder resource can be used to manage vSphere inventory folders. The resource supports creating folders of the 5 major types - datacenter folders, host and cluster folders, virtual machine folders, datastore folders, and network folders.

Paths are always relative to the specific type of folder you are creating. Subfolders are discovered by parsing the relative path specified in path, so foo/bar will create a folder named bar in the parent folder foo, as long as that folder exists.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync());
    var folder = new VSphere.Folder("folder", new VSphere.FolderArgs
    {
        DatacenterId = dc.Apply(dc => dc.Id),
        Path = "test-folder",
        Type = "vm",
    });
}

}

Example with subfolders

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync());
    var parent = new VSphere.Folder("parent", new VSphere.FolderArgs
    {
        DatacenterId = dc.Apply(dc => dc.Id),
        Path = "test-parent",
        Type = "vm",
    });
    var folder = new VSphere.Folder("folder", new VSphere.FolderArgs
    {
        DatacenterId = dc.Apply(dc => dc.Id),
        Path = parent.Path.Apply(path => $"{path}/test-folder"),
        Type = "vm",
    });
}

}

FolderArgs

FolderState

GetComputeCluster

GetComputeClusterArgs

GetComputeClusterResult

GetContentLibrary

GetContentLibraryArgs

GetContentLibraryItem

GetContentLibraryItemArgs

GetContentLibraryItemResult

GetContentLibraryResult

GetCustomAttribute

GetCustomAttributeArgs

GetCustomAttributeResult

GetDatacenter

GetDatacenterArgs

GetDatacenterResult

GetDatastore

GetDatastoreArgs

GetDatastoreCluster

GetDatastoreClusterArgs

GetDatastoreClusterResult

GetDatastoreResult

GetDistributedVirtualSwitch

GetDistributedVirtualSwitchArgs

GetDistributedVirtualSwitchResult

GetFolder

GetFolderArgs

GetFolderResult

GetHost

GetHostArgs

GetHostResult

GetNetwork

GetNetworkArgs

GetNetworkResult

GetPolicy

GetPolicyArgs

GetPolicyResult

GetResourcePool

GetResourcePoolArgs

GetResourcePoolResult

GetTag

GetTagArgs

GetTagCategory

GetTagCategoryArgs

GetTagCategoryResult

GetTagResult

GetVappContainer

GetVappContainerArgs

GetVappContainerResult

GetVirtualMachine

GetVirtualMachineArgs

GetVirtualMachineResult

GetVmfsDisks

GetVmfsDisksArgs

GetVmfsDisksResult

HaVmOverride

The vsphere..HaVmOverride resource can be used to add an override for vSphere HA settings on a cluster for a specific virtual machine. With this resource, one can control specific HA settings so that they are different than the cluster default, accommodating the needs of that specific virtual machine, while not affecting the rest of the cluster.

For more information on vSphere HA, see this page.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var cluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var vm = new VSphere.VirtualMachine("vm", new VSphere.VirtualMachineArgs
    {
        DatastoreId = datastore.Apply(datastore => datastore.Id),
        Disks = 
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 20,
            },
        },
        GuestId = "other3xLinux64Guest",
        Memory = 2048,
        NetworkInterfaces = 
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(network => network.Id),
            },
        },
        NumCpus = 2,
        ResourcePoolId = cluster.Apply(cluster => cluster.ResourcePoolId),
    });
    var haVmOverride = new VSphere.HaVmOverride("haVmOverride", new VSphere.HaVmOverrideArgs
    {
        ComputeClusterId = cluster.Apply(cluster => cluster.Id),
        HaVmRestartPriority = "highest",
        VirtualMachineId = vm.Id,
    });
}

}

HaVmOverrideArgs

HaVmOverrideState

Host

Provides a VMware vSphere host resource. This represents an ESXi host that can be used either as part of a Compute Cluster or Standalone.

Example Usage

Create a standalone host

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "my-datacenter",
    }));
    var h1 = new VSphere.Host("h1", new VSphere.HostArgs
    {
        Hostname = "10.10.10.1",
        Username = "root",
        Password = "password",
        License = "00000-00000-00000-00000i-00000",
        Datacenter = dc.Apply(dc => dc.Id),
    });
}

}

Create host in a compute cluster

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "TfDatacenter",
    }));
    var c1 = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        Name = "DC0_C0",
        DatacenterId = dc.Id,
    })));
    var h1 = new VSphere.Host("h1", new VSphere.HostArgs
    {
        Hostname = "10.10.10.1",
        Username = "root",
        Password = "password",
        License = "00000-00000-00000-00000i-00000",
        Cluster = c1.Apply(c1 => c1.Id),
    });
}

}

Importing

An existing host can be imported into this resource via supplying the host's ID. An example is below:

using Pulumi;

class MyStack : Stack
{
public MyStack()
{
}

}

The above would import the host with ID host-123.

HostArgs

HostPortGroup

The vsphere..HostPortGroup resource can be used to manage vSphere standard port groups on an ESXi host. These port groups are connected to standard virtual switches, which can be managed by the vsphere..HostVirtualSwitch resource.

For an overview on vSphere networking concepts, see this page.

Example Usage

Create a virtual switch and bind a port group to it

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var esxiHost = datacenter.Apply(datacenter => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
    {
        DatacenterId = datacenter.Id,
        Name = "esxi1",
    })));
    var @switch = new VSphere.HostVirtualSwitch("switch", new VSphere.HostVirtualSwitchArgs
    {
        ActiveNics = 
        {
            "vmnic0",
        },
        HostSystemId = esxiHost.Apply(esxiHost => esxiHost.Id),
        NetworkAdapters = 
        {
            "vmnic0",
            "vmnic1",
        },
        StandbyNics = 
        {
            "vmnic1",
        },
    });
    var pg = new VSphere.HostPortGroup("pg", new VSphere.HostPortGroupArgs
    {
        HostSystemId = esxiHost.Apply(esxiHost => esxiHost.Id),
        VirtualSwitchName = @switch.Name,
    });
}

}

Create a port group with VLAN set and some overrides

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var esxiHost = datacenter.Apply(datacenter => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
    {
        DatacenterId = datacenter.Id,
        Name = "esxi1",
    })));
    var @switch = new VSphere.HostVirtualSwitch("switch", new VSphere.HostVirtualSwitchArgs
    {
        ActiveNics = 
        {
            "vmnic0",
        },
        HostSystemId = esxiHost.Apply(esxiHost => esxiHost.Id),
        NetworkAdapters = 
        {
            "vmnic0",
            "vmnic1",
        },
        StandbyNics = 
        {
            "vmnic1",
        },
    });
    var pg = new VSphere.HostPortGroup("pg", new VSphere.HostPortGroupArgs
    {
        AllowPromiscuous = true,
        HostSystemId = esxiHost.Apply(esxiHost => esxiHost.Id),
        VirtualSwitchName = @switch.Name,
        VlanId = 4095,
    });
}

}

HostPortGroupArgs

HostPortGroupState

HostState

HostVirtualSwitch

HostVirtualSwitchArgs

HostVirtualSwitchState

License

Provides a VMware vSphere license resource. This can be used to add and remove license keys.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var licenseKey = new VSphere.License("licenseKey", new VSphere.LicenseArgs
    {
        Labels = 
        {
            { "VpxClientLicenseLabel", "Hello World" },
            { "Workflow", "Hello World" },
        },
        LicenseKey = "452CQ-2EK54-K8742-00000-00000",
    });
}

}

LicenseArgs

LicenseState

NasDatastore

The vsphere..NasDatastore resource can be used to create and manage NAS datastores on an ESXi host or a set of hosts. The resource supports mounting NFS v3 and v4.1 shares to be used as datastores.

NOTE: Unlike vsphere..VmfsDatastore, a NAS datastore is only mounted on the hosts you choose to mount it on. To mount on multiple hosts, you must specify each host that you want to add in the host_system_ids argument.

NasDatastoreArgs

NasDatastoreState

Provider

The provider type for the vsphere package. By default, resources use package-wide configuration settings, however an explicit Provider instance may be created and passed during resource construction to achieve fine-grained programmatic control over provider settings. See the documentation for more information.

ProviderArgs

ResourcePool

The vsphere..ResourcePool resource can be used to create and manage resource pools in standalone hosts or on compute clusters.

For more information on vSphere resource pools, see this page.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var config = new Config();
    var datacenter = config.Get("datacenter") ?? "dc1";
    var cluster = config.Get("cluster") ?? "cluster1";
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = datacenter,
    }));
    var computeCluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = cluster,
    })));
    var resourcePool = new VSphere.ResourcePool("resourcePool", new VSphere.ResourcePoolArgs
    {
        ParentResourcePoolId = computeCluster.Apply(computeCluster => computeCluster.ResourcePoolId),
    });
}

}

ResourcePoolArgs

ResourcePoolState

StorageDrsVmOverride

The vsphere..StorageDrsVmOverride resource can be used to add a Storage DRS override to a datastore cluster for a specific virtual machine. With this resource, one can enable or disable Storage DRS, and control the automation level and disk affinity for a single virtual machine without affecting the rest of the datastore cluster.

For more information on vSphere datastore clusters and Storage DRS, see this page.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var datastoreCluster = dc.Apply(dc => Output.Create(VSphere.GetDatastoreCluster.InvokeAsync(new VSphere.GetDatastoreClusterArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore-cluster1",
    })));
    var memberDatastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore-cluster1-member1",
    })));
    var pool = dc.Apply(dc => Output.Create(VSphere.GetResourcePool.InvokeAsync(new VSphere.GetResourcePoolArgs
    {
        DatacenterId = dc.Id,
        Name = "cluster1/Resources",
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "public",
    })));
    var vm = new VSphere.VirtualMachine("vm", new VSphere.VirtualMachineArgs
    {
        DatastoreId = memberDatastore.Apply(memberDatastore => memberDatastore.Id),
        Disks = 
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 20,
            },
        },
        GuestId = "other3xLinux64Guest",
        Memory = 1024,
        NetworkInterfaces = 
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(network => network.Id),
            },
        },
        NumCpus = 2,
        ResourcePoolId = pool.Apply(pool => pool.Id),
    });
    var drsVmOverride = new VSphere.StorageDrsVmOverride("drsVmOverride", new VSphere.StorageDrsVmOverrideArgs
    {
        DatastoreClusterId = datastoreCluster.Apply(datastoreCluster => datastoreCluster.Id),
        SdrsEnabled = false,
        VirtualMachineId = vm.Id,
    });
}

}

StorageDrsVmOverrideArgs

StorageDrsVmOverrideState

Tag

The vsphere..Tag resource can be used to create and manage tags, which allow you to attach metadata to objects in the vSphere inventory to make these objects more sortable and searchable.

For more information about tags, click here.

NOTE: Tagging support is unsupported on direct ESXi connections and requires vCenter 6.0 or higher.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var category = new VSphere.TagCategory("category", new VSphere.TagCategoryArgs
    {
        AssociableTypes = 
        {
            "VirtualMachine",
            "Datastore",
        },
        Cardinality = "SINGLE",
        Description = "Managed by Pulumi",
    });
    var tag = new VSphere.Tag("tag", new VSphere.TagArgs
    {
        CategoryId = category.Id,
        Description = "Managed by Pulumi",
    });
}

}

TagArgs

TagCategory

TagCategoryArgs

TagCategoryState

TagState

VappContainer

The vsphere..VappContainer resource can be used to create and manage vApps.

For more information on vSphere vApps, see this page.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var config = new Config();
    var datacenter = config.Get("datacenter") ?? "dc1";
    var cluster = config.Get("cluster") ?? "cluster1";
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = datacenter,
    }));
    var computeCluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = cluster,
    })));
    var vappContainer = new VSphere.VappContainer("vappContainer", new VSphere.VappContainerArgs
    {
        ParentResourcePoolId = computeCluster.Apply(computeCluster => computeCluster.Id),
    });
}

}

Example with virtual machine

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var config = new Config();
    var datacenter = config.Get("datacenter") ?? "dc1";
    var cluster = config.Get("cluster") ?? "cluster1";
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = datacenter,
    }));
    var computeCluster = dc.Apply(dc => Output.Create(VSphere.GetComputeCluster.InvokeAsync(new VSphere.GetComputeClusterArgs
    {
        DatacenterId = dc.Id,
        Name = cluster,
    })));
    var network = dc.Apply(dc => Output.Create(VSphere.GetNetwork.InvokeAsync(new VSphere.GetNetworkArgs
    {
        DatacenterId = dc.Id,
        Name = "network1",
    })));
    var datastore = dc.Apply(dc => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
    {
        DatacenterId = dc.Id,
        Name = "datastore1",
    })));
    var vappContainer = new VSphere.VappContainer("vappContainer", new VSphere.VappContainerArgs
    {
        ParentResourcePoolId = computeCluster.Apply(computeCluster => computeCluster.Id),
    });
    var vm = new VSphere.VirtualMachine("vm", new VSphere.VirtualMachineArgs
    {
        DatastoreId = datastore.Apply(datastore => datastore.Id),
        Disks = 
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 1,
            },
        },
        GuestId = "ubuntu64Guest",
        Memory = 1024,
        NetworkInterfaces = 
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(network => network.Id),
            },
        },
        NumCpus = 2,
        ResourcePoolId = vappContainer.Id,
    });
}

}

VappContainerArgs

VappContainerState

VappEntity

VappEntityArgs

VappEntityState

VirtualDisk

The vsphere..VirtualDisk resource can be used to create virtual disks outside of any given vsphere..VirtualMachine resource. These disks can be attached to a virtual machine by creating a disk block with the attach parameter.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var myDisk = new VSphere.VirtualDisk("myDisk", new VSphere.VirtualDiskArgs
    {
        Datacenter = "Datacenter",
        Datastore = "local",
        Size = 2,
        Type = "thin",
        VmdkPath = "myDisk.vmdk",
    });
}

}

VirtualDiskArgs

VirtualDiskState

VirtualMachine

VirtualMachineArgs

VirtualMachineSnapshot

The vsphere..VirtualMachineSnapshot resource can be used to manage snapshots for a virtual machine.

For more information on managing snapshots and how they work in VMware, see here.

NOTE: A snapshot in VMware differs from traditional disk snapshots, and can contain the actual running state of the virtual machine, data for all disks that have not been set to be independent from the snapshot (including ones that have been attached via the attach parameter to the vsphere..VirtualMachine disk block), and even the configuration of the virtual machine at the time of the snapshot. Virtual machine, disk activity, and configuration changes post-snapshot are not included in the original state. Use this resource with care! Neither VMware nor HashiCorp recommends retaining snapshots for a extended period of time and does NOT recommend using them as as backup feature. For more information on the limitation of virtual machine snapshots, see here.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var demo1 = new VSphere.VirtualMachineSnapshot("demo1", new VSphere.VirtualMachineSnapshotArgs
    {
        Consolidate = "true",
        Description = "This is Demo Snapshot",
        Memory = "true",
        Quiesce = "true",
        RemoveChildren = "false",
        SnapshotName = "Snapshot Name",
        VirtualMachineUuid = "9aac5551-a351-4158-8c5c-15a71e8ec5c9",
    });
}

}

VirtualMachineSnapshotArgs

VirtualMachineSnapshotState

VirtualMachineState

VmfsDatastore

The vsphere..VmfsDatastore resource can be used to create and manage VMFS datastores on an ESXi host or a set of hosts. The resource supports using any SCSI device that can generally be used in a datastore, such as local disks, or disks presented to a host or multiple hosts over Fibre Channel or iSCSI. Devices can be specified manually, or discovered using the vsphere..getVmfsDisks data source.

Auto-Mounting of Datastores Within vCenter

Note that the current behaviour of this resource will auto-mount any created datastores to any other host within vCenter that has access to the same disk.

Example: You want to create a datastore with a iSCSI LUN that is visible on 3 hosts in a single vSphere cluster (esxi1, esxi2 and esxi3). When you create the datastore on esxi1, the datastore will be automatically mounted on esxi2 and esxi3, without the need to configure the resource on either of those two hosts.

Future versions of this resource may allow you to control the hosts that a datastore is mounted to, but currently, this automatic behaviour cannot be changed, so keep this in mind when writing your configurations and deploying your disks.

Increasing Datastore Size

To increase the size of a datastore, you must add additional disks to the disks attribute. Expanding the size of a datastore by increasing the size of an already provisioned disk is currently not supported (but may be in future versions of this resource).

NOTE: You cannot decrease the size of a datastore. If the resource detects disks removed from the configuration, the provider will give an error.

Example Usage

Addition of local disks on a single host

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync());
    var esxiHost = datacenter.Apply(datacenter => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
    {
        DatacenterId = datacenter.Id,
    })));
    var datastore = new VSphere.VmfsDatastore("datastore", new VSphere.VmfsDatastoreArgs
    {
        Disks = 
        {
            "mpx.vmhba1:C0:T1:L0",
            "mpx.vmhba1:C0:T2:L0",
            "mpx.vmhba1:C0:T2:L0",
        },
        HostSystemId = esxiHost.Apply(esxiHost => esxiHost.Id),
    });
}

}

Auto-detection of disks via vsphere..getVmfsDisks

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "dc1",
    }));
    var esxiHost = datacenter.Apply(datacenter => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
    {
        DatacenterId = datacenter.Id,
        Name = "esxi1",
    })));
    var available = esxiHost.Apply(esxiHost => Output.Create(VSphere.GetVmfsDisks.InvokeAsync(new VSphere.GetVmfsDisksArgs
    {
        Filter = "naa.60a98000",
        HostSystemId = esxiHost.Id,
        Rescan = true,
    })));
    var datastore = new VSphere.VmfsDatastore("datastore", new VSphere.VmfsDatastoreArgs
    {
        Disks = available.Apply(available => available.Disks),
        Folder = "datastore-folder",
        HostSystemId = esxiHost.Apply(esxiHost => esxiHost.Id),
    });
}

}

VmfsDatastoreArgs

VmfsDatastoreState

Vnic

Provides a VMware vSphere vnic resource.

Example Usages

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

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
public MyStack()
{
    var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
    {
        Name = "mydc",
    }));
    var h1 = dc.Apply(dc => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
    {
        Name = "esxi1.host.test",
        DatacenterId = dc.Id,
    })));
    var hvs1 = new VSphere.HostVirtualSwitch("hvs1", new VSphere.HostVirtualSwitchArgs
    {
        HostSystemId = h1.Apply(h1 => h1.Id),
        NetworkAdapters = 
        {
            "vmnic3",
            "vmnic4",
        },
        ActiveNics = 
        {
            "vmnic3",
        },
        StandbyNics = 
        {
            "vmnic4",
        },
    });
    var p1 = new VSphere.HostPortGroup("p1", new VSphere.HostPortGroupArgs
    {
        VirtualSwitchName = hvs1.Name,
        HostSystemId = h1.Apply(h1 => h1.Id),
    });
    var v1 = new VSphere.Vnic("v1", new VSphere.VnicArgs
    {
        Host = h1.Apply(h1 => h1.Id),
        Portgroup = p1.Name,
        Ipv4 = new VSphere.Inputs.VnicIpv4Args
        {
            Dhcp = true,
        },
    });
}

}

Importing

An existing vNic can be imported into this resource via supplying the vNic's ID. An example is below:

using Pulumi;

class MyStack : Stack
{
public MyStack()
{
}

}

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

VnicArgs

VnicState

Back to top Copyright 2016-2020, Pulumi Corporation.