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

getTag

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 support is unsupported on direct ESXi connections and requires vCenter 6.0 or higher.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
    public MyStack()
    {
        var category = Output.Create(VSphere.GetTagCategory.InvokeAsync(new VSphere.GetTagCategoryArgs
        {
            Name = "test-category",
        }));
        var tag = category.Apply(category => Output.Create(VSphere.GetTag.InvokeAsync(new VSphere.GetTagArgs
        {
            CategoryId = category.Id,
            Name = "test-tag",
        })));
    }

}
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 {
        category, err := vsphere.LookupTagCategory(ctx, &vsphere.LookupTagCategoryArgs{
            Name: "test-category",
        }, nil)
        if err != nil {
            return err
        }
        _, err = vsphere.LookupTag(ctx, &vsphere.LookupTagArgs{
            CategoryId: category.Id,
            Name:       "test-tag",
        }, nil)
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_vsphere as vsphere

category = vsphere.get_tag_category(name="test-category")
tag = vsphere.get_tag(category_id=category.id,
    name="test-tag")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const category = pulumi.output(vsphere.getTagCategory({
    name: "test-category",
}, { async: true }));
const tag = category.apply(category => vsphere.getTag({
    categoryId: category.id,
    name: "test-tag",
}, { async: true }));

Using getTag

function getTag(args: GetTagArgs, opts?: InvokeOptions): Promise<GetTagResult>
def get_tag(category_id: Optional[str] = None, name: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetTagResult
func LookupTag(ctx *Context, args *LookupTagArgs, opts ...InvokeOption) (*LookupTagResult, error)

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

public static class GetTag {
    public static Task<GetTagResult> InvokeAsync(GetTagArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

CategoryId string

The ID of the tag category the tag is located in.

Name string

The name of the tag.

CategoryId string

The ID of the tag category the tag is located in.

Name string

The name of the tag.

categoryId string

The ID of the tag category the tag is located in.

name string

The name of the tag.

category_id str

The ID of the tag category the tag is located in.

name str

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
category_id str
description str
id str

The provider-assigned unique ID for this managed resource.

name 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.