iām trying to create multiple Network interfaces by using for_each and locals, here is my code
locals {
network_interfaces = {
a = {
subnet_id = module.vpc.public_subnets[0],
security_group = [aws_security_group.ssh.id],
},
b = {
subnet_id = module.vpc.public_subnets[0],
security_groups = [aws_security_group.ssh.id],
},
c = {
subnet_id = module.vpc.public_subnets[1],
security_groups = [aws_security_group.ssh.id],
},
d = {
subnet_id = module.vpc.public_subnets[1],
security_groups = [aws_security_group.ssh.id],
},
}
}
and here iām trying to iterate over the local.network_interfaces with for_each so I can create 4 network interfaces
resource "aws_network_interface" "this" {
for_each = local.network_interfaces
subnet_id = each.value.subnet_id
security_groups = each.value.security_groups
tags = {
Name = "${each.key}_network_interface"
}
}
but when i run Terraform apply, it gives me this error
ā Error: Unsupported attribute
ā
ā on main.tf line 61, in resource "aws_network_interface" "this":
ā 61: security_groups = each.value.security_groups
ā āāāāāāāāāāāāāāāāā
ā ā each.value is object with 2 attributes
ā
ā This object does not have an attribute named "security_groups"
any help will be appreciated