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

vsphere.getTag

Explore with Pulumi AI

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

    The vsphere.Tag data source can be used to reference tags that are not managed by this provider. Its attributes are exactly the same as the vsphere.Tag resource, and, like importing, the data source takes a name and category to search on. The id and other attributes are then populated with the data found by the search.

    NOTE: Tagging is not supported on direct ESXi hosts connections and requires vCenter Server.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const category = vsphere.getTagCategory({
        name: "example-category",
    });
    const tag = category.then(category => vsphere.getTag({
        name: "example-tag",
        categoryId: category.id,
    }));
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    category = vsphere.get_tag_category(name="example-category")
    tag = vsphere.get_tag(name="example-tag",
        category_id=category.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 {
    		category, err := vsphere.LookupTagCategory(ctx, &vsphere.LookupTagCategoryArgs{
    			Name: "example-category",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = vsphere.LookupTag(ctx, &vsphere.LookupTagArgs{
    			Name:       "example-tag",
    			CategoryId: category.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 category = VSphere.GetTagCategory.Invoke(new()
        {
            Name = "example-category",
        });
    
        var tag = VSphere.GetTag.Invoke(new()
        {
            Name = "example-tag",
            CategoryId = category.Apply(getTagCategoryResult => getTagCategoryResult.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.GetTagCategoryArgs;
    import com.pulumi.vsphere.inputs.GetTagArgs;
    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("example-category")
                .build());
    
            final var tag = VsphereFunctions.getTag(GetTagArgs.builder()
                .name("example-tag")
                .categoryId(category.applyValue(getTagCategoryResult -> getTagCategoryResult.id()))
                .build());
    
        }
    }
    
    variables:
      category:
        fn::invoke:
          Function: vsphere:getTagCategory
          Arguments:
            name: example-category
      tag:
        fn::invoke:
          Function: vsphere:getTag
          Arguments:
            name: example-tag
            categoryId: ${category.id}
    

    Using getTag

    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 getTag(args: GetTagArgs, opts?: InvokeOptions): Promise<GetTagResult>
    function getTagOutput(args: GetTagOutputArgs, opts?: InvokeOptions): Output<GetTagResult>
    def get_tag(category_id: Optional[str] = None,
                name: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetTagResult
    def get_tag_output(category_id: Optional[pulumi.Input[str]] = None,
                name: Optional[pulumi.Input[str]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetTagResult]
    func LookupTag(ctx *Context, args *LookupTagArgs, opts ...InvokeOption) (*LookupTagResult, error)
    func LookupTagOutput(ctx *Context, args *LookupTagOutputArgs, opts ...InvokeOption) LookupTagResultOutput

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

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

    The following arguments are supported:

    CategoryId string
    The ID of the tag category in which the tag is located.
    Name string
    The name of the tag.
    CategoryId string
    The ID of the tag category in which the tag is located.
    Name string
    The name of the tag.
    categoryId String
    The ID of the tag category in which the tag is located.
    name String
    The name of the tag.
    categoryId string
    The ID of the tag category in which the tag is located.
    name string
    The name of the tag.
    category_id str
    The ID of the tag category in which the tag is located.
    name str
    The name of the tag.
    categoryId String
    The ID of the tag category in which the tag is located.
    name String
    The name of the tag.

    getTag Result

    The following output properties are available:

    CategoryId string
    Description string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    CategoryId string
    Description string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    categoryId String
    description String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    categoryId string
    description string
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    category_id str
    description str
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    categoryId String
    description String
    id String
    The provider-assigned unique ID for this managed resource.
    name 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