我有条件地创建一个带有计数的资源:
resource "aws_kms_key" "this" {
count = var.create_kms_key == true ? 1 : 0
...
}
那么我如何有条件地输出这个资源的价值呢?我试着到处玩,Terraform 似乎自相矛盾
首先它告诉我在输出中使用计数。
For example, to correlate with indices of a referring resource, use:
aws_kms_key.this[count.index]
然后当我尝试它说我不能使用计数时。
The "count" object can be used only in "resource" and "data" blocks, and only
when the "count" argument is set.
以前我们可以执行以下操作,但现在这会触发我之前发布的计数错误。
output "kms_key_arn" {
value = aws_kms_key.this.*.arn
}
知道这现在是如何工作的吗?
谢谢,