How To - Terraform 0.12 dynamically tagging GKE cluster

8/29/2019

Has anyone use the terraform 0.12 to declare dynamic tagging for GKE cluster?? If so, please share some insight and enlighten me on this.

Looking at the GKE terraform [resource_label] block, it would not allow me to declare a tag in there.

I thought was something like below.

locals {
 test = {
     x = "y"
     a = "b"
  }
}

resource "gke_container" "test" {
 tag {
  key = "name"
  value = "example_name"
  propagate_at_launch = true
  }

dynamic "tag" {
 for_each = local.test
 content {
   key = "tag.key"
   value = "tag.value"
 }
}
-- Lee.Tan
google-cloud-platform
google-kubernetes-engine
terraform0.12+

0 Answers