I want to bind a tag for GKE cluster but not unable because:
google_tags_tag_binding.gke-tag-value-binding: Creating...
╷
│ Error: Error creating TagBinding: googleapi: Error 400: Request contains an invalid argument.
│ Details:
│ [
│ {
│ "@type": "type.googleapis.com/google.rpc.BadRequest",
│ "fieldViolations": [
│ {
│ "description": "Must be a valid One Platform resource name of a tag-compatible global resource. Did you forget to specify the correct location?",
│ "field": "binding.resource"
│ },
│ {
│ "description": "Resource type not supported in location global",
│ "field": "binding.resource"
│ }
│ ]
│ }
│ ]
│
│ with google_tags_tag_binding.gke-tag-value-binding,
│ on main.tf line 162, in resource "google_tags_tag_binding" "gke-tag-value-binding":
│ 162: resource "google_tags_tag_binding" "gke-tag-value-binding" {
│
╵
Terraform plan:
Terraform will perform the following actions:
# google_tags_tag_binding.gke-tag-value-binding will be created
+ resource "google_tags_tag_binding" "gke-tag-value-binding" {
+ id = (known after apply)
+ name = (known after apply)
+ parent = "//container.googleapis.com/projects/xxx/locations/asia-southeast2-a/clusters/gke-cluster"
+ tag_value = "tagValues/xxx"
}
My code related to tag:
resource "google_tags_tag_key" "gke-tag" {
parent = "projects/${var.gcp-proj}"
short_name = "gke-cluster"
description = ""
}
resource "google_tags_tag_value" "gke-tag-value" {
parent = google_tags_tag_key.gke-tag.id
short_name = "gke-cluster-true"
description = "It's True"
}
resource "google_tags_tag_binding" "gke-tag-value-binding" {
provider = google.oprek
parent = "//container.googleapis.com/${google_container_cluster.gke-cluster.id}"
tag_value = google_tags_tag_value.gke-tag-value.id
}
What’s wrong with my Terraform configuration? I think the code defined is right and following the documenatation.
Related documentation:
Google Cloud Doc: Manage GKE resources using Tags
Terraform Registry Doc: Google Provider - resource.google_tags_tag_binding