vSphere v4.13.2 published on Wednesday, Apr 9, 2025 by Pulumi
vsphere.getDatastore
Explore with Pulumi AI
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
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,
}));
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)
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
})
}
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 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.id())
.build());
}
}
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,
stats: Optional[Mapping[str, str]] = None,
opts: Optional[InvokeOptions] = None) -> GetDatastoreResult
def get_datastore_output(datacenter_id: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
stats: Optional[pulumi.Input[Mapping[str, 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)
public static Output<GetDatastoreResult> getDatastore(GetDatastoreArgs args, InvokeOptions options)
fn::invoke:
function: vsphere:index/getDatastore:getDatastore
arguments:
# arguments dictionaryThe following arguments are supported:
- Name string
- The name of the datastore. This can be a name or path.
- Datacenter
Id string - The managed object reference ID
of the datacenter the datastore is located in. This can be omitted if the
search path used in
nameis an absolute path. For default datacenters, use theidattribute from an emptyvsphere.Datacenterdata source. - Stats Dictionary<string, string>
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- Name string
- The name of the datastore. This can be a name or path.
- Datacenter
Id string - The managed object reference ID
of the datacenter the datastore is located in. This can be omitted if the
search path used in
nameis an absolute path. For default datacenters, use theidattribute from an emptyvsphere.Datacenterdata source. - Stats map[string]string
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- name String
- The name of the datastore. This can be a name or path.
- datacenter
Id String - The managed object reference ID
of the datacenter the datastore is located in. This can be omitted if the
search path used in
nameis an absolute path. For default datacenters, use theidattribute from an emptyvsphere.Datacenterdata source. - stats Map<String,String>
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- name string
- The name of the datastore. This can be a name or path.
- datacenter
Id string - The managed object reference ID
of the datacenter the datastore is located in. This can be omitted if the
search path used in
nameis an absolute path. For default datacenters, use theidattribute from an emptyvsphere.Datacenterdata source. - stats {[key: string]: string}
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- 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
nameis an absolute path. For default datacenters, use theidattribute from an emptyvsphere.Datacenterdata source. - stats Mapping[str, str]
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- name String
- The name of the datastore. This can be a name or path.
- datacenter
Id String - The managed object reference ID
of the datacenter the datastore is located in. This can be omitted if the
search path used in
nameis an absolute path. For default datacenters, use theidattribute from an emptyvsphere.Datacenterdata source. - stats Map<String>
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
getDatastore Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- Datacenter
Id string - Stats Dictionary<string, string>
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- Datacenter
Id string - Stats map[string]string
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- datacenter
Id String - stats Map<String,String>
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- id string
- The provider-assigned unique ID for this managed resource.
- name string
- datacenter
Id string - stats {[key: string]: string}
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- id str
- The provider-assigned unique ID for this managed resource.
- name str
- datacenter_
id str - stats Mapping[str, str]
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- datacenter
Id String - stats Map<String>
- The disk space usage statistics for the specific datastore. The
total datastore capacity is represented as
capacityand the free remaining disk is represented asfree.
Package Details
- Repository
- vSphere pulumi/pulumi-vsphere
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
vsphereTerraform Provider.