UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

160 lines 6.3 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! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TagBinding = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * A TagBinding represents a connection between a TagValue and a cloud resource (currently project, folder, or organization). Once a TagBinding is created, the TagValue is applied to all the descendants of the cloud resource. * * To get more information about TagBinding, see: * * * [API documentation](https://docs.cloud.google.com/resource-manager/reference/rest/v3/tagBindings) * * How-to Guides * * [Official Documentation](https://docs.cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing) * * ## Example Usage * * ### Tag Binding Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = new gcp.organizations.Project("project", { * projectId: "project_id", * name: "project_id", * orgId: "123456789", * deletionPolicy: "DELETE", * }); * const key = new gcp.tags.TagKey("key", { * parent: "organizations/123456789", * shortName: "keyname", * description: "For keyname resources.", * }); * const value = new gcp.tags.TagValue("value", { * parent: key.id, * shortName: "valuename", * description: "For valuename resources.", * }); * const binding = new gcp.tags.TagBinding("binding", { * parent: pulumi.interpolate`//cloudresourcemanager.googleapis.com/projects/${project.number}`, * tagValue: value.id, * }); * ``` * ### Tag Binding Using Dynamic Tag Value * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = new gcp.organizations.Project("project", { * projectId: "project_id", * name: "project_id", * orgId: "123456789", * deletionPolicy: "DELETE", * }); * const key = new gcp.tags.TagKey("key", { * parent: "organizations/123456789", * shortName: "keyname", * description: "For keyname resources.", * allowedValuesRegex: "^[a-z]+$", * }); * const binding = new gcp.tags.TagBinding("binding", { * parent: pulumi.interpolate`//cloudresourcemanager.googleapis.com/projects/${project.number}`, * tagValue: pulumi.interpolate`${key.namespacedName}/test-value`, * }); * ``` * * ## Import * * TagBinding can be imported using any of these accepted formats: * * * `tagBindings/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, TagBinding can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:tags/tagBinding:TagBinding default tagBindings/{{name}} * $ pulumi import gcp:tags/tagBinding:TagBinding default {{name}} * ``` */ class TagBinding extends pulumi.CustomResource { /** * Get an existing TagBinding 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 TagBinding(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:tags/tagBinding:TagBinding'; /** * Returns true if the given object is an instance of TagBinding. 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'] === TagBinding.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["name"] = state?.name; resourceInputs["parent"] = state?.parent; resourceInputs["tagValue"] = state?.tagValue; } else { const args = argsOrState; if (args?.parent === undefined && !opts.urn) { throw new Error("Missing required property 'parent'"); } if (args?.tagValue === undefined && !opts.urn) { throw new Error("Missing required property 'tagValue'"); } resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["parent"] = args?.parent; resourceInputs["tagValue"] = args?.tagValue; resourceInputs["name"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(TagBinding.__pulumiType, name, resourceInputs, opts); } } exports.TagBinding = TagBinding; //# sourceMappingURL=tagBinding.js.map