1. Packages
  2. Vsphere Provider
  3. API Docs
  4. getDatacenter
vSphere v4.16.1 published on Wednesday, Oct 22, 2025 by Pulumi

vsphere.getDatacenter

Start a Neo task
Explain and create a vsphere.getDatacenter resource
vsphere logo
vSphere v4.16.1 published on Wednesday, Oct 22, 2025 by Pulumi

    The vsphere.Datacenter data source can be used to discover the ID of a vSphere datacenter object. This can then be used with resources or data sources that require a datacenter, such as the vsphere.Host data source.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const datacenter = vsphere.getDatacenter({
        name: "dc-01",
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    datacenter = vsphere.get_datacenter(name="dc-01")
    
    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 {
    		_, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
    			Name: pulumi.StringRef("dc-01"),
    		}, 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",
        });
    
    });
    
    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 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());
    
        }
    }
    
    variables:
      datacenter:
        fn::invoke:
          function: vsphere:getDatacenter
          arguments:
            name: dc-01
    

    Using getDatacenter

    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 getDatacenter(args: GetDatacenterArgs, opts?: InvokeOptions): Promise<GetDatacenterResult>
    function getDatacenterOutput(args: GetDatacenterOutputArgs, opts?: InvokeOptions): Output<GetDatacenterResult>
    def get_datacenter(name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetDatacenterResult
    def get_datacenter_output(name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetDatacenterResult]
    func LookupDatacenter(ctx *Context, args *LookupDatacenterArgs, opts ...InvokeOption) (*LookupDatacenterResult, error)
    func LookupDatacenterOutput(ctx *Context, args *LookupDatacenterOutputArgs, opts ...InvokeOption) LookupDatacenterResultOutput

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

    public static class GetDatacenter 
    {
        public static Task<GetDatacenterResult> InvokeAsync(GetDatacenterArgs args, InvokeOptions? opts = null)
        public static Output<GetDatacenterResult> Invoke(GetDatacenterInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetDatacenterResult> getDatacenter(GetDatacenterArgs args, InvokeOptions options)
    public static Output<GetDatacenterResult> getDatacenter(GetDatacenterArgs args, InvokeOptions options)
    
    fn::invoke:
      function: vsphere:index/getDatacenter:getDatacenter
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string

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

    NOTE: When used with an ESXi host, this data source always returns the host's "default" datacenter, which is a special datacenter name unrelated to the datacenters that exist in the vSphere inventory when managed by a vCenter Server instance. Hence, the name attribute is completely ignored.

    Name string

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

    NOTE: When used with an ESXi host, this data source always returns the host's "default" datacenter, which is a special datacenter name unrelated to the datacenters that exist in the vSphere inventory when managed by a vCenter Server instance. Hence, the name attribute is completely ignored.

    name String

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

    NOTE: When used with an ESXi host, this data source always returns the host's "default" datacenter, which is a special datacenter name unrelated to the datacenters that exist in the vSphere inventory when managed by a vCenter Server instance. Hence, the name attribute is completely ignored.

    name string

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

    NOTE: When used with an ESXi host, this data source always returns the host's "default" datacenter, which is a special datacenter name unrelated to the datacenters that exist in the vSphere inventory when managed by a vCenter Server instance. Hence, the name attribute is completely ignored.

    name str

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

    NOTE: When used with an ESXi host, this data source always returns the host's "default" datacenter, which is a special datacenter name unrelated to the datacenters that exist in the vSphere inventory when managed by a vCenter Server instance. Hence, the name attribute is completely ignored.

    name String

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

    NOTE: When used with an ESXi host, this data source always returns the host's "default" datacenter, which is a special datacenter name unrelated to the datacenters that exist in the vSphere inventory when managed by a vCenter Server instance. Hence, the name attribute is completely ignored.

    getDatacenter Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    VirtualMachines List<string>
    List of all virtual machines included in the vSphere datacenter object.
    Name string
    Id string
    The provider-assigned unique ID for this managed resource.
    VirtualMachines []string
    List of all virtual machines included in the vSphere datacenter object.
    Name string
    id String
    The provider-assigned unique ID for this managed resource.
    virtualMachines List<String>
    List of all virtual machines included in the vSphere datacenter object.
    name String
    id string
    The provider-assigned unique ID for this managed resource.
    virtualMachines string[]
    List of all virtual machines included in the vSphere datacenter object.
    name string
    id str
    The provider-assigned unique ID for this managed resource.
    virtual_machines Sequence[str]
    List of all virtual machines included in the vSphere datacenter object.
    name str
    id String
    The provider-assigned unique ID for this managed resource.
    virtualMachines List<String>
    List of all virtual machines included in the vSphere datacenter object.
    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.16.1 published on Wednesday, Oct 22, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate