1. Packages
  2. vSphere
  3. API Docs
  4. getHost
vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi

vsphere.getHost

Explore with Pulumi AI

vsphere logo
vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi

    The vsphere.Host data source can be used to discover the ID of an ESXi host. This can then be used with resources or data sources that require an ESX host’s managed object reference ID.

    Example Usage

    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,
    }));
    
    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)
    
    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
    		}
    		_, err = vsphere.LookupHost(ctx, &vsphere.LookupHostArgs{
    			Name:         pulumi.StringRef("esxi-01.example.com"),
    			DatacenterId: datacenter.Id,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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),
        });
    
    });
    
    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 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());
    
        }
    }
    
    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}
    

    Using getHost

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

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

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

    public static class GetHost 
    {
        public static Task<GetHostResult> InvokeAsync(GetHostArgs args, InvokeOptions? opts = null)
        public static Output<GetHostResult> Invoke(GetHostInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetHostResult> getHost(GetHostArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: vsphere:index/getHost:getHost
      arguments:
        # arguments dictionary

    The following arguments are supported:

    DatacenterId string
    The managed object reference ID of a vSphere datacenter object.
    Name string

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

    NOTE: When used against an ESXi host directly, this data source always returns the ESXi host's object ID, regardless of what is entered into name.

    DatacenterId string
    The managed object reference ID of a vSphere datacenter object.
    Name string

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

    NOTE: When used against an ESXi host directly, this data source always returns the ESXi host's object ID, regardless of what is entered into name.

    datacenterId String
    The managed object reference ID of a vSphere datacenter object.
    name String

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

    NOTE: When used against an ESXi host directly, this data source always returns the ESXi host's object ID, regardless of what is entered into name.

    datacenterId string
    The managed object reference ID of a vSphere datacenter object.
    name string

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

    NOTE: When used against an ESXi host directly, this data source always returns the ESXi host's object ID, regardless of what is entered into name.

    datacenter_id str
    The managed object reference ID of a vSphere datacenter object.
    name str

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

    NOTE: When used against an ESXi host directly, this data source always returns the ESXi host's object ID, regardless of what is entered into name.

    datacenterId String
    The managed object reference ID of a vSphere datacenter object.
    name String

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

    NOTE: When used against an ESXi host directly, this data source always returns the ESXi host's object ID, regardless of what is entered into name.

    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 ESXi 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 ESXi 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 ESXi 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 ESXi 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 ESXi host's root resource pool.
    name str
    datacenterId String
    id String
    The provider-assigned unique ID for this managed resource.
    resourcePoolId String
    The managed object ID of the ESXi host's root resource pool.
    name String

    Package Details

    Repository
    vSphere pulumi/pulumi-vsphere
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vsphere Terraform Provider.
    vsphere logo
    vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi