google_tags_location_tag_binding

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:

Example Usage - Cloud Run Service

To bind a tag to a Cloud Run service:

resource "google_project" "project" {
    project_id = "project_id"
    name       = "project_id"
    org_id     = "123456789"
}

resource "google_tags_tag_key" "key" {
    parent      = "organizations/123456789"
    short_name  = "keyname"
    description = "For keyname resources."
}

resource "google_tags_tag_value" "value" {
    parent      = "tagKeys/${google_tags_tag_key.key.name}"
    short_name  = "valuename"
    description = "For valuename resources."
}

resource "google_tags_location_tag_binding" "binding" {
    parent    = "//run.googleapis.com/projects/${data.google_project.project.number}/locations/${google_cloud_run_service.default.location}/services/${google_cloud_run_service.default.name}"
    tag_value = "tagValues/${google_tags_tag_value.value.name}"
    location  = "us-central1"
}

Example Usage - Compute Instance

resource "google_project" "project" {
    project_id = "project_id"
    name       = "project_id"
    org_id     = "123456789"
}

resource "google_tags_tag_key" "key" {
    parent      = "organizations/123456789"
    short_name  = "keyname"
    description = "For keyname resources."
}

resource "google_tags_tag_value" "value" {
    parent      = "tagKeys/${google_tags_tag_key.key.name}"
    short_name  = "valuename"
    description = "For valuename resources."
}

resource "google_tags_location_tag_binding" "binding" {
    parent    = "//compute.googleapis.com/projects/${google_project.project.number}/zones/us-central1-a/instances/${google_compute_instance.instance.instance_id}"
    tag_value = "tagValues/${google_tags_tag_value.value.name}"
    location  = "us-central1-a"
}

Argument Reference

The following arguments are supported:


Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

LocationTagBinding can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import TagBinding using one of the formats above. For example:

import {
  id = "{{location}}/{{name}}"
  to = google_tags_location_tag_binding.default
}

When using the terraform import command, TagBinding can be imported using one of the formats above. For example:

$ terraform import google_tags_location_tag_binding.default {{location}}/{{name}}