I’m trying to do something similar to the following snippet using a for_each
:
locals {
remote = [
"alpha",
"bravo",
"charlie"
]
}
resource "aws_security_group_rule" "sg_rule" {
for_each = toset(local.remote)
type = "ingress"
from_port = 1000
to_port = 1000
protocol = "tcp"
source_security_group_id = var.${each.value}
security_group_id = "sg-123456789"
}
Terraform doesn’t like this, if I cast var.${each.value}
to a string this obviously doesn’t work either. Is this kind of interpolation just not possible? I’ve had a look through the docs and can’t see anything helpful.
Should this be raised as a feature request?