use*_*856 3 interpolation list terraform
我想知道是否有可能在 terraform 中获得列表的总数,我查看了 tf 网站,但没有看到任何有关仅使用 count.index 的总数的信息。
示例列表
var "testList"
type = "list"
default [
{
type = "test1"
},
{
type = "test2"
}
]
Run Code Online (Sandbox Code Playgroud)
所以在这里我想得到 2 作为测试列表的总数
谢谢
您可以使用 terraform 内置函数length()来获取计数。
count = "${length(var.testList)}"
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请查看 terraform 文档: