从远程状态的子网列表中筛选可用性区域?

时间:2019-10-28 22:37:16

标签: terraform

我目前正在Terraterra中设置MSK集群。可用区us-east-1e不适用于MSK。我的列表是在远程状态文件中生成的。可以在不修改原始文件的情况下调用该列表并筛选出us-east-1e的子网吗?

resource "aws_msk_cluster" "example" {
  cluster_name           = "msk-cluster-${var.env}"
  kafka_version          = "2.2.1"
  number_of_broker_nodes = 3

  broker_node_group_info {
    instance_type   = "kafka.m5.large"
    ebs_volume_size = "1000"
    client_subnets  = [ "${data.terraform_remote_state.vpc.public_subnet_ids}" ] // needs to exclude us-east-1e
  }
}

1 个答案:

答案 0 :(得分:0)

如果您使用Terraform 0.12或更高版本,则可以使用for-expression

client_subnets = [for az in data.terraform_remote_state.vpc.public_subnet_ids: az if az != "us-east-1e"]