Kubernetes supports dots in metadata label keys (for example app.role), and indeed this seems to be a common convention.
The terraform configuration language (0.12) doesn't support dots in argument names, so labels of this form cannot be specified. For example in a google_container_node_pool configuration, I want to specify this:
resource "google_container_node_pool" "my-node-pool" {
...
labels = {
app.role = web
}
}
Is there a workaround?
note: slashes (/) are quite common in k8s labels as well..
UPDATE: in case anyone stumbles on this same issue down the road, I figured out the root of my issue. I had incorrectly specified the labels argument as a block by omitting the =. So it looked like this:
labels {
"app.role" = "web"
}
This yielded the following error, which pointed me in the wrong direction:
Error: Invalid argument name
on main.tf line 45, in resource "google_container_node_pool" "primary_preemptible_nodes":
45: "app.role" = "web"
Argument names must not be quoted.
I noticed and fixed the missing = but I didn't put it together that map keys have different syntax from argument names.