1. Packages
  2. Vsphere Provider
  3. API Docs
  4. getTag
vSphere v4.13.2 published on Wednesday, Apr 9, 2025 by Pulumi

vsphere.getTag

Explore with Pulumi AI

vSphere v4.13.2 published on Wednesday, Apr 9, 2025 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,
}));
Copy
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)
Copy
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
	})
}
Copy
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),
    });

});
Copy
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.id())
            .build());

    }
}
Copy
variables:
  category:
    fn::invoke:
      function: vsphere:getTagCategory
      arguments:
        name: example-category
  tag:
    fn::invoke:
      function: vsphere:getTag
      arguments:
        name: example-tag
        categoryId: ${category.id}
Copy

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>
Copy
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]
Copy
func LookupTag(ctx *Context, args *LookupTagArgs, opts ...InvokeOption) (*LookupTagResult, error)
func LookupTagOutput(ctx *Context, args *LookupTagOutputArgs, opts ...InvokeOption) LookupTagResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetTagResult> getTag(GetTagArgs args, InvokeOptions options)
public static Output<GetTagResult> getTag(GetTagArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: vsphere:index/getTag:getTag
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

CategoryId This property is required. string
The ID of the tag category in which the tag is located.
Name This property is required. string
The name of the tag.
CategoryId This property is required. string
The ID of the tag category in which the tag is located.
Name This property is required. string
The name of the tag.
categoryId This property is required. String
The ID of the tag category in which the tag is located.
name This property is required. String
The name of the tag.
categoryId This property is required. string
The ID of the tag category in which the tag is located.
name This property is required. string
The name of the tag.
category_id This property is required. str
The ID of the tag category in which the tag is located.
name This property is required. str
The name of the tag.
categoryId This property is required. String
The ID of the tag category in which the tag is located.
name This property is required. 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 v4.13.2 published on Wednesday, Apr 9, 2025 by Pulumi