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

getHost

The vsphere.Host data source can be used to discover the ID of a vSphere host. This can then be used with resources or data sources that require a host managed object reference ID.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
    public MyStack()
    {
        var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
        {
            Name = "dc1",
        }));
        var host = datacenter.Apply(datacenter => Output.Create(VSphere.GetHost.InvokeAsync(new VSphere.GetHostArgs
        {
            DatacenterId = datacenter.Id,
            Name = "esxi1",
        })));
    }

}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        opt0 := "dc1"
        datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
            Name: &opt0,
        }, nil)
        if err != nil {
            return err
        }
        opt1 := "esxi1"
        _, err = vsphere.LookupHost(ctx, &vsphere.LookupHostArgs{
            DatacenterId: datacenter.Id,
            Name:         &opt1,
        }, nil)
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_vsphere as vsphere

datacenter = vsphere.get_datacenter(name="dc1")
host = vsphere.get_host(datacenter_id=datacenter.id,
    name="esxi1")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const datacenter = pulumi.output(vsphere.getDatacenter({
    name: "dc1",
}, { async: true }));
const host = datacenter.apply(datacenter => vsphere.getHost({
    datacenterId: datacenter.id,
    name: "esxi1",
}, { async: true }));

Using getHost

function getHost(args: GetHostArgs, opts?: InvokeOptions): Promise<GetHostResult>
def get_host(datacenter_id: Optional[str] = None, name: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetHostResult
func LookupHost(ctx *Context, args *LookupHostArgs, opts ...InvokeOption) (*LookupHostResult, error)

Note: This function is named LookupHost in the Go SDK.

public static class GetHost {
    public static Task<GetHostResult> InvokeAsync(GetHostArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

DatacenterId string

The managed object reference ID of a datacenter.

Name string

The name of the host. This can be a name or path. Can be omitted if there is only one host in your inventory.

DatacenterId string

The managed object reference ID of a datacenter.

Name string

The name of the host. This can be a name or path. Can be omitted if there is only one host in your inventory.

datacenterId string

The managed object reference ID of a datacenter.

name string

The name of the host. This can be a name or path. Can be omitted if there is only one host in your inventory.

datacenter_id str

The managed object reference ID of a datacenter.

name str

The name of the host. This can be a name or path. Can be omitted if there is only one host in your inventory.

getHost Result

The following output properties are available:

DatacenterId string
Id string

The provider-assigned unique ID for this managed resource.

ResourcePoolId string

The managed object ID of the host’s root resource pool.

Name string
DatacenterId string
Id string

The provider-assigned unique ID for this managed resource.

ResourcePoolId string

The managed object ID of the host’s root resource pool.

Name string
datacenterId string
id string

The provider-assigned unique ID for this managed resource.

resourcePoolId string

The managed object ID of the host’s root resource pool.

name string
datacenter_id str
id str

The provider-assigned unique ID for this managed resource.

resource_pool_id str

The managed object ID of the host’s root resource pool.

name str

Package Details

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