我有带有AmazonMQ的配置模块
module "amazonmq_cluster" {
source = "git::https://github.com/cloudposse/terraform-aws-mq-broker.git?ref=0.15.0"
namespace = module.amazonmq_cluster_label.namespace
stage = module.amazonmq_cluster_label.stage
name = module.amazonmq_cluster_label.id
apply_immediately = true
auto_minor_version_upgrade = false
deployment_mode = var.cluster_deployment_mode[local.stage]
engine_type = var.cluster_engine_type[local.stage]
engine_version = var.cluster_engine_version[local.stage]
host_instance_type = var.cluster_host_instance_type[local.stage]
publicly_accessible = false
general_log_enabled = true
audit_log_enabled = false
encryption_enabled = true
use_aws_owned_key = true
vpc_id = module.vpc.vpc_id
subnet_ids = var.cluster_deployment_mode[local.stage] != "ACTIVE_STANDBY_MULTI_AZ" ? module.vpc.private_subnet_ids[0] : module.vpc.private_subnet_ids
security_groups = [module.sg.groups]
}并且我需要用字符串的变量映射有条件地描述subnet_ids。字符串映射设置为terraform工作区。但是,当我尝试创建模块terraform时,用不一致的条件结果类型给出错误。
Error: Inconsistent conditional result types
on amazonmq.tf line 31, in module "amazonmq_cluster":
31: subnet_ids = var.cluster_deployment_mode[local.stage] != "ACTIVE_STANDBY_MULTI_AZ" ? module.vpc.private_subnet_ids[0] : module.vpc.private_subnet_ids
|----------------
| local.stage is "staging"
| module.vpc.private_subnet_ids is tuple with 2 elements
| module.vpc.private_subnet_ids[0] is "XXX"
| var.cluster_deployment_mode is map of string with 3 elements我怎样才能正确设置这个条件?如果!=ACTIVE_STANDBY_MULTI_AZ传递一个VPC ID,否则从输出传递所有。
发布于 2021-11-03 20:24:32
我怎样才能正确设置这个条件?如果!=ACTIVE_STANDBY_MULTI_AZ传递一个VPC ID,否则从输出传递所有。
尝试将此作为表达式:
var.cluster_deployment_mode[local.stage] != "ACTIVE_STANDBY_MULTI_AZ" ? [module.vpc.private_subnet_ids[0]] : module.vpc.private_subnet_ids它为第一个选项构建一个单一元素列表。
https://stackoverflow.com/questions/69829673
复制相似问题