vSphere

Pulumi Official
Package maintained by Pulumi
v4.1.0 published on Wednesday, Nov 24, 2021 by Pulumi

getDatastore

The vsphere.getDatastore data source can be used to discover the ID of a datastore in vSphere. This is useful to fetch the ID of a datastore that you want to use to create virtual machines in using the vsphere.VirtualMachine resource.

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 datastore = datacenter.Apply(datacenter => Output.Create(VSphere.GetDatastore.InvokeAsync(new VSphere.GetDatastoreArgs
        {
            DatacenterId = datacenter.Id,
            Name = "datastore1",
        })));
    }

}
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 {
		opt0 := "dc1"
		datacenter, err := vsphere.LookupDatacenter(ctx, &GetDatacenterArgs{
			Name: &opt0,
		}, nil)
		if err != nil {
			return err
		}
		opt1 := datacenter.Id
		_, err = vsphere.GetDatastore(ctx, &GetDatastoreArgs{
			DatacenterId: &opt1,
			Name:         "datastore1",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}

Coming soon!

import pulumi
import pulumi_vsphere as vsphere

datacenter = vsphere.get_datacenter(name="dc1")
datastore = vsphere.get_datastore(datacenter_id=datacenter.id,
    name="datastore1")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const datacenter = pulumi.output(vsphere.getDatacenter({
    name: "dc1",
}));
const datastore = datacenter.apply(datacenter => vsphere.getDatastore({
    datacenterId: datacenter.id,
    name: "datastore1",
}));

Coming soon!

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
https://github.com/pulumi/pulumi-vsphere
License
Apache-2.0
Notes

This Pulumi package is based on the vsphere Terraform Provider.