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/v2/go/vsphere"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
opt0 := "dc1"
datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
Name: &opt0,
}, nil)
if err != nil {
return err
}
opt1 := datacenter.Id
_, err = vsphere.GetDatastore(ctx, &vsphere.GetDatastoreArgs{
DatacenterId: &opt1,
Name: "datastore1",
}, nil)
if err != nil {
return err
}
return nil
})
}
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",
}, { async: true }));
const datastore = datacenter.apply(datacenter => vsphere.getDatastore({
datacenterId: datacenter.id,
name: "datastore1",
}, { async: true }));
Using getDatastore
function getDatastore(args: GetDatastoreArgs, opts?: InvokeOptions): Promise<GetDatastoreResult>
def get_datastore(datacenter_id: Optional[str] = None, name: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetDatastoreResult
func GetDatastore(ctx *Context, args *GetDatastoreArgs, opts ...InvokeOption) (*GetDatastoreResult, error)
Note: This function is named
GetDatastore
in the Go SDK.
public static class GetDatastore {
public static Task<GetDatastoreResult> InvokeAsync(GetDatastoreArgs args, InvokeOptions? opts = null)
}
The 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
name
is an absolute path. For default datacenters, use the id attribute from an emptyvsphere.Datacenter
data source.
- 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
name
is an absolute path. For default datacenters, use the id attribute from an emptyvsphere.Datacenter
data source.
- 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
name
is an absolute path. For default datacenters, use the id attribute from an emptyvsphere.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 emptyvsphere.Datacenter
data source.
getDatastore Result
The following output properties are available:
- Id string
The provider-assigned unique ID for this managed resource.
- Name string
- Datacenter
Id string
- Id string
The provider-assigned unique ID for this managed resource.
- Name string
- Datacenter
Id string
- id string
The provider-assigned unique ID for this managed resource.
- name string
- datacenter
Id string
- id str
The provider-assigned unique ID for this managed resource.
- name str
- datacenter_
id str
Package Details
- Repository
- https://github.com/pulumi/pulumi-vsphere
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
vsphere
Terraform Provider.