1. Packages
  2. Vsphere Provider
  3. API Docs
  4. getDynamic
vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi

vsphere.getDynamic

Explore with Pulumi AI

vsphere logo
vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi

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

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const category = vsphere.getTagCategory({
        name: "SomeCategory",
    });
    const tag1 = vsphere.getTag({
        name: "FirstTag",
        categoryId: cat.id,
    });
    const tag2 = 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",
    }));
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    category = 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")
    
    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 {
    _, 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
    }
    _, err = vsphere.GetDynamic(ctx, &vsphere.GetDynamicArgs{
    Filters: interface{}{
    tag1.Id,
    tag1.Id,
    },
    NameRegex: pulumi.StringRef("ubuntu"),
    Type: pulumi.StringRef("Datacenter"),
    }, 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 category = VSphere.GetTagCategory.Invoke(new()
        {
            Name = "SomeCategory",
        });
    
        var tag1 = VSphere.GetTag.Invoke(new()
        {
            Name = "FirstTag",
            CategoryId = cat.Id,
        });
    
        var tag2 = VSphere.GetTag.Invoke(new()
        {
            Name = "SecondTag",
            CategoryId = cat.Id,
        });
    
        var dyn = VSphere.GetDynamic.Invoke(new()
        {
            Filters = new[]
            {
                tag1.Apply(getTagResult => getTagResult.Id),
                tag1.Apply(getTagResult => getTagResult.Id),
            },
            NameRegex = "ubuntu",
            Type = "Datacenter",
        });
    
    });
    
    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.GetTagCategoryArgs;
    import com.pulumi.vsphere.inputs.GetTagArgs;
    import com.pulumi.vsphere.inputs.GetDynamicArgs;
    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 category = VsphereFunctions.getTagCategory(GetTagCategoryArgs.builder()
                .name("SomeCategory")
                .build());
    
            final var tag1 = VsphereFunctions.getTag(GetTagArgs.builder()
                .name("FirstTag")
                .categoryId(cat.id())
                .build());
    
            final var tag2 = VsphereFunctions.getTag(GetTagArgs.builder()
                .name("SecondTag")
                .categoryId(cat.id())
                .build());
    
            final var dyn = VsphereFunctions.getDynamic(GetDynamicArgs.builder()
                .filters(            
                    tag1.applyValue(getTagResult -> getTagResult.id()),
                    tag1.applyValue(getTagResult -> getTagResult.id()))
                .nameRegex("ubuntu")
                .type("Datacenter")
                .build());
    
        }
    }
    
    variables:
      category:
        fn::invoke:
          Function: vsphere:getTagCategory
          Arguments:
            name: SomeCategory
      tag1:
        fn::invoke:
          Function: vsphere:getTag
          Arguments:
            name: FirstTag
            categoryId: ${cat.id}
      tag2:
        fn::invoke:
          Function: vsphere:getTag
          Arguments:
            name: SecondTag
            categoryId: ${cat.id}
      dyn:
        fn::invoke:
          Function: vsphere:getDynamic
          Arguments:
            filters:
              - ${tag1.id}
              - ${tag1.id}
            nameRegex: ubuntu
            type: Datacenter
    

    Using getDynamic

    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 getDynamic(args: GetDynamicArgs, opts?: InvokeOptions): Promise<GetDynamicResult>
    function getDynamicOutput(args: GetDynamicOutputArgs, opts?: InvokeOptions): Output<GetDynamicResult>
    def get_dynamic(filters: Optional[Sequence[str]] = None,
                    name_regex: Optional[str] = None,
                    type: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetDynamicResult
    def get_dynamic_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                    name_regex: Optional[pulumi.Input[str]] = None,
                    type: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetDynamicResult]
    func GetDynamic(ctx *Context, args *GetDynamicArgs, opts ...InvokeOption) (*GetDynamicResult, error)
    func GetDynamicOutput(ctx *Context, args *GetDynamicOutputArgs, opts ...InvokeOption) GetDynamicResultOutput

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

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

    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. The managed object types can be found in the managed object type section 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. The managed object types can be found in the managed object type section here.
    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. The managed object types can be found in the managed object type section 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. The managed object types can be found in the managed object type section 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. The managed object types can be found in the managed object type section here.
    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. The managed object types can be found in the managed object type section 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 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 Sequence[str]
    id str
    The provider-assigned unique ID for this managed resource.
    name_regex str
    type str
    filters List<String>
    id String
    The provider-assigned unique ID for this managed resource.
    nameRegex String
    type 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.12.1 published on Tuesday, Oct 22, 2024 by Pulumi