我希望在我指定的任何区域的“ a”或“ b”可用性区域中启动一个子网-有没有办法让terraform做到这一点?
与此类似:
variable "az" {
default = {
a = 1
b = 2
}
}
resource "aws_subnet" "example" {
vpc_id = aws_vpc.vpc.id
availability_zone = var.az.(places subnets in either of the specified AZs)
}
你可以简单地获取当前区域名称,并在其后附加a
或b
字符,如下所示:
data "aws_region" "current" {}
locals {
az1 = "${data.aws_region.current.name}a"
az2 = "${data.aws_region.current.name}b"
}
太好了,非常感谢!