You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Especially when using a map or list of resources, it can be useful to create an expression based on the each object. If this expression is used in more than one place, there can be a significant amount of duplication of code, OR you have to define a local write a local.
Attempted Solutions
variable "map" {
type = map(number)
}
locals {
ABC = { for k, v in var.map: k => something(v) }
}
resource aws_something "something" {
for_each = var.map
attribute = expression(local.ABC[each.value])
}
Terraform Version
Use Cases
Especially when using a map or list of resources, it can be useful to create an expression based on the
each
object. If this expression is used in more than one place, there can be a significant amount of duplication of code, OR you have to define a local write a local.Attempted Solutions
Proposal
References
No response
The text was updated successfully, but these errors were encountered: