Terraform Defaults and Local
From Federal Burro of Information
Now you tfvars file can have only defaults for larger groups of vars.
variable "liveness_default" { type = map default = { health_threshold = 1 interval = 5 logging = true path = "/health" timeout = 1 unhealth_threshold = 2 } } variable "liveness" { type = map default = {} } locals { liveness = merge(var.liveness_default, var.liveness) } resource google_liveness_thingy "mylivenessthingy" { name = "${var.name}-liveness-probe" health_threshold = local.liveness["health_threshold"] interval = local.liveness["interval"] logging = local.liveness["logging"] path = local.liveness["path"] timeout = local.liveness["timeout"] unhealth_threshold = local.liveness["unhealth_threshold"] }