1. Packages
  2. vSphere
  3. API Docs
  4. getDatastore
vSphere v4.9.0 published on Tuesday, Nov 28, 2023 by Pulumi

vsphere.getDatastore

Explore with Pulumi AI

vsphere logo
vSphere v4.9.0 published on Tuesday, Nov 28, 2023 by Pulumi

    The vsphere.getDatastore data source can be used to discover the ID of a vSphere datastore object. This can then be used with resources or data sources that require a datastore. For example, to create virtual machines in using the vsphere.VirtualMachine resource.

    Example Usage

    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 datastore = VSphere.GetDatastore.Invoke(new()
        {
            Name = "datastore-01",
            DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.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.GetDatastore(ctx, &vsphere.GetDatastoreArgs{
    			Name:         "datastore-01",
    			DatacenterId: pulumi.StringRef(datacenter.Id),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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.GetDatastoreArgs;
    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 datastore = VsphereFunctions.getDatastore(GetDatastoreArgs.builder()
                .name("datastore-01")
                .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    datacenter = vsphere.get_datacenter(name="dc-01")
    datastore = vsphere.get_datastore(name="datastore-01",
        datacenter_id=datacenter.id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const datacenter = vsphere.getDatacenter({
        name: "dc-01",
    });
    const datastore = datacenter.then(datacenter => vsphere.getDatastore({
        name: "datastore-01",
        datacenterId: datacenter.id,
    }));
    
    variables:
      datacenter:
        fn::invoke:
          Function: vsphere:getDatacenter
          Arguments:
            name: dc-01
      datastore:
        fn::invoke:
          Function: vsphere:getDatastore
          Arguments:
            name: datastore-01
            datacenterId: ${datacenter.id}
    

    Using getDatastore

    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 getDatastore(args: GetDatastoreArgs, opts?: InvokeOptions): Promise<GetDatastoreResult>
    function getDatastoreOutput(args: GetDatastoreOutputArgs, opts?: InvokeOptions): Output<GetDatastoreResult>
    def get_datastore(datacenter_id: Optional[str] = None,
                      name: Optional[str] = None,
                      opts: Optional[InvokeOptions] = None) -> GetDatastoreResult
    def get_datastore_output(datacenter_id: Optional[pulumi.Input[str]] = None,
                      name: Optional[pulumi.Input[str]] = None,
                      opts: Optional[InvokeOptions] = None) -> Output[GetDatastoreResult]
    func GetDatastore(ctx *Context, args *GetDatastoreArgs, opts ...InvokeOption) (*GetDatastoreResult, error)
    func GetDatastoreOutput(ctx *Context, args *GetDatastoreOutputArgs, opts ...InvokeOption) GetDatastoreResultOutput

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

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

    The following arguments are supported:

    Name string

    The name of the datastore. This can be a name or path.

    DatacenterId string

    The managed object reference ID of the datacenter the datastore is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    Name string

    The name of the datastore. This can be a name or path.

    DatacenterId string

    The managed object reference ID of the datacenter the datastore is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    name String

    The name of the datastore. This can be a name or path.

    datacenterId String

    The managed object reference ID of the datacenter the datastore is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    name string

    The name of the datastore. This can be a name or path.

    datacenterId string

    The managed object reference ID of the datacenter the datastore is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    name str

    The name of the datastore. This can be a name or path.

    datacenter_id str

    The managed object reference ID of the datacenter the datastore is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    name String

    The name of the datastore. This can be a name or path.

    datacenterId String

    The managed object reference ID of the datacenter the datastore is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    getDatastore Result

    The following output properties are available:

    Id string

    The provider-assigned unique ID for this managed resource.

    Name string
    DatacenterId string
    Id string

    The provider-assigned unique ID for this managed resource.

    Name string
    DatacenterId string
    id String

    The provider-assigned unique ID for this managed resource.

    name String
    datacenterId String
    id string

    The provider-assigned unique ID for this managed resource.

    name string
    datacenterId string
    id str

    The provider-assigned unique ID for this managed resource.

    name str
    datacenter_id str
    id String

    The provider-assigned unique ID for this managed resource.

    name String
    datacenterId 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.9.0 published on Tuesday, Nov 28, 2023 by Pulumi