diff --git a/examples/managed-node-pools/example.tf b/examples/managed-node-pools/example.tf index f56234d..ba8823e 100644 --- a/examples/managed-node-pools/example.tf +++ b/examples/managed-node-pools/example.tf @@ -129,4 +129,10 @@ module "gke" { preemptible = true } ] + + enable_resource_labels = false + + resource_labels = { + "env" = "production" + } } \ No newline at end of file diff --git a/examples/self-hosted-node-pools/example.tf b/examples/self-hosted-node-pools/example.tf index 6a445e1..f99f2ee 100644 --- a/examples/self-hosted-node-pools/example.tf +++ b/examples/self-hosted-node-pools/example.tf @@ -127,4 +127,10 @@ module "gke" { preemptible = true } ] + + enable_resource_labels = false + + resource_labels = { + "env" = "production" + } } \ No newline at end of file diff --git a/main.tf b/main.tf index f3f890a..b5239b2 100644 --- a/main.tf +++ b/main.tf @@ -37,6 +37,8 @@ resource "google_container_cluster" "primary" { } } + resource_labels = var.enable_resource_labels ? var.resource_labels : {} + cluster_autoscaling { enabled = var.cluster_autoscaling diff --git a/variables.tf b/variables.tf index 766970d..7a64279 100644 --- a/variables.tf +++ b/variables.tf @@ -300,4 +300,14 @@ variable "enable_master_authorized_networks" { default = true } +variable "enable_resource_labels" { + description = "Flag to enable or disable GCE resource labels." + type = bool + default = false +} +variable "resource_labels" { + description = "Resource labels for GCE resources." + type = map(string) + default = {} +}