Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

getDynamic

The vsphere.getDynamic data source can be used to get the managed object reference ID of any tagged managed object in vCenter by providing a list of tag IDs and an optional regular expression to filter objects by name.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
    public MyStack()
    {
        var cat = Output.Create(VSphere.GetTagCategory.InvokeAsync(new VSphere.GetTagCategoryArgs
        {
            Name = "SomeCategory",
        }));
        var tag1 = cat.Apply(cat => Output.Create(VSphere.GetTag.InvokeAsync(new VSphere.GetTagArgs
        {
            Name = "FirstTag",
            CategoryId = cat.Id,
        })));
        var tag2 = cat.Apply(cat => Output.Create(VSphere.GetTag.InvokeAsync(new VSphere.GetTagArgs
        {
            Name = "SecondTag",
            CategoryId = cat.Id,
        })));
        var dyn = Output.Tuple(tag1, tag1).Apply(values =>
        {
            var tag1 = values.Item1;
            var tag11 = values.Item2;
            return Output.Create(VSphere.GetDynamic.InvokeAsync(new VSphere.GetDynamicArgs
            {
                Filters = 
                {
                    tag1.Id,
                    tag11.Id,
                },
                NameRegex = "ubuntu",
                Type = "Datacenter",
            }));
        });
    }

}
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 {
        cat, err := vsphere.LookupTagCategory(ctx, &vsphere.LookupTagCategoryArgs{
            Name: "SomeCategory",
        }, nil)
        if err != nil {
            return err
        }
        tag1, err := vsphere.LookupTag(ctx, &vsphere.LookupTagArgs{
            Name:       "FirstTag",
            CategoryId: cat.Id,
        }, nil)
        if err != nil {
            return err
        }
        _, err = vsphere.LookupTag(ctx, &vsphere.LookupTagArgs{
            Name:       "SecondTag",
            CategoryId: cat.Id,
        }, nil)
        if err != nil {
            return err
        }
        opt0 := "ubuntu"
        opt1 := "Datacenter"
        _, err = vsphere.GetDynamic(ctx, &vsphere.GetDynamicArgs{
            Filters: []string{
                tag1.Id,
                tag1.Id,
            },
            NameRegex: &opt0,
            Type:      &opt1,
        }, nil)
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_vsphere as vsphere

cat = vsphere.get_tag_category(name="SomeCategory")
tag1 = vsphere.get_tag(name="FirstTag",
    category_id=cat.id)
tag2 = vsphere.get_tag(name="SecondTag",
    category_id=cat.id)
dyn = vsphere.get_dynamic(filters=[
        tag1.id,
        tag1.id,
    ],
    name_regex="ubuntu",
    type="Datacenter")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const cat = vsphere.getTagCategory({
    name: "SomeCategory",
});
const tag1 = cat.then(cat => vsphere.getTag({
    name: "FirstTag",
    categoryId: cat.id,
}));
const tag2 = cat.then(cat => vsphere.getTag({
    name: "SecondTag",
    categoryId: cat.id,
}));
const dyn = Promise.all([tag1, tag1]).then(([tag1, tag11]) => vsphere.getDynamic({
    filters: [
        tag1.id,
        tag11.id,
    ],
    nameRegex: "ubuntu",
    type: "Datacenter",
}));

Using getDynamic

function getDynamic(args: GetDynamicArgs, opts?: InvokeOptions): Promise<GetDynamicResult>
def get_dynamic(filters: Optional[Sequence[str]] = None, name_regex: Optional[str] = None, type: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetDynamicResult
func GetDynamic(ctx *Context, args *GetDynamicArgs, opts ...InvokeOption) (*GetDynamicResult, error)

Note: This function is named GetDynamic in the Go SDK.

public static class GetDynamic {
    public static Task<GetDynamicResult> InvokeAsync(GetDynamicArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<string>

A list of tag IDs that must be present on an object to be a match.

NameRegex string

A regular expression that will be used to match the object’s name.

Type string

The managed object type the returned object must match. For a full list, click here.

Filters []string

A list of tag IDs that must be present on an object to be a match.

NameRegex string

A regular expression that will be used to match the object’s name.

Type string

The managed object type the returned object must match. For a full list, click here.

filters string[]

A list of tag IDs that must be present on an object to be a match.

nameRegex string

A regular expression that will be used to match the object’s name.

type string

The managed object type the returned object must match. For a full list, click here.

filters Sequence[str]

A list of tag IDs that must be present on an object to be a match.

name_regex str

A regular expression that will be used to match the object’s name.

type str

The managed object type the returned object must match. For a full list, click here.

getDynamic Result

The following output properties are available:

Filters List<string>
Id string

The provider-assigned unique ID for this managed resource.

NameRegex string
Type string
Filters []string
Id string

The provider-assigned unique ID for this managed resource.

NameRegex string
Type string
filters string[]
id string

The provider-assigned unique ID for this managed resource.

nameRegex string
type string
filters Sequence[str]
id str

The provider-assigned unique ID for this managed resource.

name_regex str
type 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.