Closed nirojan closed 2 years ago
Duplicate of #1462
I resolved as below.
locals {
environment_settings = {
(var.env) = {
a = "b"
c = "d"
}
}
}
See: https://www.terraform.io/language/expressions/types#maps-objects
You can use a non-literal string expression as a key by wrapping it in parentheses, like
(var.business_unit_tag_name) = "SRE"
.
Introduction
Tflint warns about using deprecated terraform interpolation when Terraform suggests that I do use the old interpolation when using a variable as key in locals.
Expected Behavior
tflint doesn't warn about old interpolation behaviour in this case as that is what Terraform suggests I do, or it will error.
Actual behavior
Tflint warns interpolation that is required by Terraform.
Step to Reproduce
Additional Context
Terraform error if I make the change suggested by tflint