From terraform 0.12, you can fake a switch by using maps, e.g.
locals {
environments = {
prod = "east",
prod2 = "west2"
}
region = lookup(environment_region, lower(var.environment), "west")
}
Advantage of this is if the result is more complex you can return objects/lists from the map, rather than simple strings.
For example, I have a centralized naming module that composes name according to different rules based on the resource type etc.
locals {
parts_map = {
# NB Location should always be last to ensure geo-separation of names
prefix = [ local.type.code, var.name, var.role, var.environment, module.location.code ]
suffix = [ var.name, var.role, var.environment, local.type.code, module.location.code ]
mode3 = [ var.name, local.type.code, var.role, var.environment, module.location.code ]
}
parts = compact(local.parts_map[local.type.order])