If I have a variables in my terraform module, such as:
variable "environment" {
type = string
}
within my module, I'm using locals to define some items specific to environments:
locals {
dev = {
foo=bar
}
}
Within the module where locals is, how can I use the passed in environment variable to access the corresponding key in locals?
locals.${var.environment}.foo is what I'm going to, where var.environment will evaluate to dev.
Something like this?
local[var.environment]["foo"]