Collection Functions
Terraform supports a huge number of functions that work with collection types such as list
, tuple
, set
, or map
. In this section, you will briefly look at the most common ones. The examples used in the section will be available with the filename 4. collection-functions.txt
in the GitHub provided at the start of this chapter.
Since these functions can work with different collection types, you will be skipping the syntax part and looking at the examples directly.
The alltrue() Function
The alltrue()
function will return true
(Boolean type) if all the input elements in the list/tuple are true
(Boolean type value) or true (string
value).
Some examples are as follows:
$ alltrue([true, true])
> true
$ alltrue([true, false])
> false
The anytrue() Function
This function returns true
if any of the elements in the input collection has true
(Boolean type value) or true (string
value).
Some examples are as follows:
$ anytrue([true,...