UNPKG

@pulumi/vsphere

Version:

A Pulumi package for creating vsphere resources

140 lines 4.89 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Tag = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * The `vsphere.Tag` resource can be used to create and manage tags, which allow * you to attach metadata to objects in the vSphere inventory to make these * objects more sortable and searchable. * * For more information about tags, click [here][ext-tags-general]. * * [ext-tags-general]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-tags-and-attributes.html * * ## Example Usage * * This example creates a tag named `test-tag`. This tag is assigned the * `test-category` category, which was created by the * `vsphere.TagCategory` resource. The resulting * tag can be assigned to VMs and datastores only, and can be the only value in * the category that can be assigned, as per the restrictions defined by the * category. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const category = new vsphere.TagCategory("category", { * name: "test-category", * cardinality: "SINGLE", * description: "Managed by Pulumi", * associableTypes: [ * "VirtualMachine", * "Datastore", * ], * }); * const tag = new vsphere.Tag("tag", { * name: "test-tag", * categoryId: category.id, * description: "Managed by Pulumi", * }); * ``` * * ### Using Tags in a Supported Resource * * Tags can be applied to vSphere resources via the `tags` argument * in any supported resource. * * The following example builds on the above example by creating a * `vsphere.VirtualMachine` and applying the * created tag to it: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vsphere from "@pulumi/vsphere"; * * const category = new vsphere.TagCategory("category", { * name: "test-category", * cardinality: "SINGLE", * description: "Managed by Pulumi", * associableTypes: [ * "VirtualMachine", * "Datastore", * ], * }); * const tag = new vsphere.Tag("tag", { * name: "test-tag", * categoryId: category.id, * description: "Managed by Pulumi", * }); * const web = new vsphere.VirtualMachine("web", {tags: [tag.id]}); * ``` * * ## Import * * An existing tag can be imported into this resource by supplying * * both the tag's category name and the name of the tag as a JSON string to * * `pulumi import`, as per the example below: * * [docs-import]: https://developer.hashicorp.com/terraform/cli/import * * ```sh * $ pulumi import vsphere:index/tag:Tag tag \ * ``` * * '{"category_name": "pulumi-test-category", "tag_name": "pulumi-test-tag"}' */ class Tag extends pulumi.CustomResource { /** * Get an existing Tag resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Tag(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Tag. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Tag.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["categoryId"] = state?.categoryId; resourceInputs["description"] = state?.description; resourceInputs["name"] = state?.name; } else { const args = argsOrState; if (args?.categoryId === undefined && !opts.urn) { throw new Error("Missing required property 'categoryId'"); } resourceInputs["categoryId"] = args?.categoryId; resourceInputs["description"] = args?.description; resourceInputs["name"] = args?.name; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Tag.__pulumiType, name, resourceInputs, opts); } } exports.Tag = Tag; /** @internal */ Tag.__pulumiType = 'vsphere:index/tag:Tag'; //# sourceMappingURL=tag.js.map