Hi,
I am trying to manage the labels consistency using default_labels for google provider. But how can I use a default_labels value inside resource block to create a resource from the tag value.
eg. in my providers.tf I have mentioned like this:
provider "google" {
project = "my-project"
region = "us-central1"
default_labels = {
managed_by = "Terraform"
app-env = "dev"
workspace-name = var.TFC_WORKSPACE_NAME
}
}
Now Suppose I have some user defined labels in my locals.tf.
user_labels = {
app_name = "google_pubsub_topic"
}
How can I merge them in my pubsub resource.
resource "google_pubsub_topic" "topic" {
name = "my_pubsub_topic"
labels = merge(provider.default_labels, local.user_labels) # is this possible?
...
}
Also how can I validate if the some lifecycle precondition or postconditions that the value provided in default_labels inside provider declaration is valid or not. How to reference the value ?