Reputation: 67
I am wondering if it's possible to get the total count of a list in terraform, I've looked at the tf website and don't see anything for the total count just the use of count.index.
An example list
var "testList"
type = "list"
default [
{
type = "test1"
},
{
type = "test2"
}
]
So here I want to get 2 as the total count of testlist
Thanks
Upvotes: 3
Views: 5621
Reputation: 45313
you can use terraform built-in function length()
to get the count.
count = "${length(var.testList)}"
For details, please go through terraform documents:
Upvotes: 6