我有一个创建SQS队列的顶级资源。 我的子模块继承了资源并根据项目输入创建SQS队列。
main.tf
module "incoming_queue1" {
source = "github.com/dummy/terraform-sqs"
sqs_queue_name = "incoming_queue1"
}
module "outgoing_queue1" {
source = "github.com/dummy/terraform-sqs"
sqs_queue_name = "outgoing_queue1"
}
module "incoming_queue2" {
source = "github.com/dummy/terraform-sqs"
sqs_queue_name = "incoming_queue1"
}
module "outgoing_queue2" {
source = "github.com/dummy/terraform-sqs"
sqs_queue_name = "outgoing_queue1"
}
outputs.tf
output "incoming_queue1" {
value = "${module.incoming_queue1.id}"
}
output "outgoing_queue1" {
value = "${module.outgoing_queue1.id}"
}
output "incoming_queue2" {
value = "${module.incoming_queue2.id}"
}
output "outgoing_queue2" {
value = "${module.outgoing_queue2.id}"
}
痛苦地添加所有输出,我想看看是否存在将所有输出组合起来并放入它的逻辑。也许是地形formatlist
。简单的输出,如
outputs.tf
output "sqs_queues" {
value = "${
formatlist(
"{\"%v\": \"%v\"}",
module.*.id,
module.*.arn,
)
}"
}
这样我就不必为每个队列提供都管理output.tf。