将动态嵌套列表输入terraform setproduct()函数
问题:将动态嵌套列表输入terraform setproduct()函数,terraform,Terraform,问题: bar = [ [ {"honda" = "passport"}, {"toyota" = "prius"} ], [ {"honda" = "civic"}, {"toyota" = "prius"} ] ] 我有一个动态嵌套列表,我想输入到terraform函数中。我不能将嵌套
bar = [
[
{"honda" = "passport"},
{"toyota" = "prius"}
],
[
{"honda" = "civic"},
{"toyota" = "prius"}
]
]
我有一个动态嵌套列表,我想输入到terraform函数中。我不能将嵌套列表直接传递给setproduct()函数,也不能使用for循环在setproduct()函数中迭代嵌套列表(请参见第节)。setproduct()函数仅在我显式定义2个或多个单级列表参数时才起作用(请参见预期输出部分)
输入:(子列表是动态创建的,这意味着子列表索引范围会发生变化)
预期输出:
bar = [
[
{"honda" = "passport"},
{"toyota" = "prius"}
],
[
{"honda" = "civic"},
{"toyota" = "prius"}
]
]
可以使用下面的输出块创建预期的输出。尽管如问题部分所述,local.foo嵌套列表具有动态的第二级索引范围。因此,明确定义[0]
和[1]
标记并不是一个可行的解决方案
output "bar" {
value = setproduct(local.foo[0], local.foo[1])
}
尝试:
bar = [
[
{"honda" = "passport"},
{"toyota" = "prius"}
],
[
{"honda" = "civic"},
{"toyota" = "prius"}
]
]
#1
output "bar" {
value = setproduct(local.foo)
}
输出错误:
on test.tf line 35, in output "attempts":
35: value = setproduct(local.foo)
|----------------
| local.foo is tuple with 2 elements
Call to function "setproduct" failed: at least two arguments are required.
on test.tf line 35, in output "attempts":
35: value = setproduct(local.foo[*])
|----------------
| local.foo is tuple with 2 elements
Call to function "setproduct" failed: at least two arguments are required.
#2
output "bar" {
value = setproduct(local.foo[*])
}
输出错误:
on test.tf line 35, in output "attempts":
35: value = setproduct(local.foo)
|----------------
| local.foo is tuple with 2 elements
Call to function "setproduct" failed: at least two arguments are required.
on test.tf line 35, in output "attempts":
35: value = setproduct(local.foo[*])
|----------------
| local.foo is tuple with 2 elements
Call to function "setproduct" failed: at least two arguments are required.
我想你在追求:
直到现在才知道TF DSL有一个“splat”类型的操作符。@MattSchuchard它可能非常简单:-)当然,我们需要注意术语,因为它在地形中已经意味着其他东西了D