terraform 需要来自私有的子网 ID 和 public 子网的 nacl 关联
terraform need subnets ids from private and public subnet for nacl association
我们需要私下使用子网,并且 public 在 terraform nacl 中关联。
如何获取两个子网的id?
vpc_id = aws_vpc.vpc.id
subnet_ids = aws_subnet.public_subnet.*.id
egress {
protocol = "tcp"
rule_no = 200
action = "allow"
cidr_block = "10.3.0.0/18"
from_port = 443
to_port = 443
}
同样需要获取私有子网。
aws_subnet.private_subnet.*.id
如何同时获得私有和 public 子网
您可以concat ID:
locals {
all_subnet_ids = concat(aws_subnet.public_subnet.*.id, aws_subnet.private_subnet.*.id)
}
我们需要私下使用子网,并且 public 在 terraform nacl 中关联。
如何获取两个子网的id?
vpc_id = aws_vpc.vpc.id
subnet_ids = aws_subnet.public_subnet.*.id
egress {
protocol = "tcp"
rule_no = 200
action = "allow"
cidr_block = "10.3.0.0/18"
from_port = 443
to_port = 443
}
同样需要获取私有子网。
aws_subnet.private_subnet.*.id
如何同时获得私有和 public 子网
您可以concat ID:
locals {
all_subnet_ids = concat(aws_subnet.public_subnet.*.id, aws_subnet.private_subnet.*.id)
}