@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
142 lines • 5.67 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocationTagBinding = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* A LocationTagBinding represents a connection between a TagValue and a non-global target such as a Cloud Run Service or Compute Instance. Once a LocationTagBinding is created, the TagValue is applied to all the descendants of the cloud resource.
*
* To get more information about LocationTagBinding, see:
*
* * [API documentation](https://cloud.google.com/resource-manager/reference/rest/v3/tagBindings)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing)
*
* ## Example Usage
*
* ### Cloud Run Service
*
* To bind a tag to a Cloud Run service:
*
* ```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",
* });
* 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.LocationTagBinding("binding", {
* parent: `//run.googleapis.com/projects/${projectGoogleProject.number}/locations/${_default.location}/services/${_default.name}`,
* tagValue: value.id,
* location: "us-central1",
* });
* ```
*
* ### Compute Instance
*
* ```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",
* });
* 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.LocationTagBinding("binding", {
* parent: pulumi.interpolate`//compute.googleapis.com/projects/${project.number}/zones/us-central1-a/instances/${instance.instanceId}`,
* tagValue: value.id,
* location: "us-central1-a",
* });
* ```
*
* ## Import
*
* LocationTagBinding can be imported using any of these accepted formats:
*
* * `{{location}}/{{name}}`
*
* When using the `pulumi import` command, TagBinding can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:tags/locationTagBinding:LocationTagBinding default {{location}}/{{name}}
* ```
*/
class LocationTagBinding extends pulumi.CustomResource {
/**
* Get an existing LocationTagBinding 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 LocationTagBinding(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of LocationTagBinding. 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'] === LocationTagBinding.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["location"] = state ? state.location : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["parent"] = state ? state.parent : undefined;
resourceInputs["tagValue"] = state ? state.tagValue : undefined;
}
else {
const args = argsOrState;
if ((!args || args.parent === undefined) && !opts.urn) {
throw new Error("Missing required property 'parent'");
}
if ((!args || args.tagValue === undefined) && !opts.urn) {
throw new Error("Missing required property 'tagValue'");
}
resourceInputs["location"] = args ? args.location : undefined;
resourceInputs["parent"] = args ? args.parent : undefined;
resourceInputs["tagValue"] = args ? args.tagValue : undefined;
resourceInputs["name"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(LocationTagBinding.__pulumiType, name, resourceInputs, opts);
}
}
exports.LocationTagBinding = LocationTagBinding;
/** @internal */
LocationTagBinding.__pulumiType = 'gcp:tags/locationTagBinding:LocationTagBinding';
//# sourceMappingURL=locationTagBinding.js.map