alltrue checks a whole list at once: it returns true only when every item is true. Combined with a for expression, it checks one rule for every item, such as “every name has text”.
Syntax
Syntax
alltrue(<LIST>)
<LIST>: a list oftrueandfalsevalues. The docs also accept the text"true".
The function is described in alltrue Function in the OpenTofu® docs.
Prerequisites
- OpenTofu installed. Installing OpenTofu in the OpenTofu docs covers every system.
Step 1: Try It in tofu console
Open a terminal in any empty folder and start tofu console, which evaluates expressions as you type them:
Terminal
tofu console
Type each expression to see the result:
tofu console
> alltrue([true, true, true])
true
> alltrue([true, false])
false
> alltrue([])
true
> alltrue(["true", true])
true
> exit
Clean Up
Type exit to leave the console. The example creates nothing, so there’s nothing else to remove.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Expecting alltrue([]) to be false | An empty list returns true: there’s no item that isn’t true. | Check the list’s length separately when an empty list isn’t allowed. |
| Using it to check whether any item is true | It needs all of them. | Use anytrue for “at least one”. |
FAQ
What can the list contain?
Bool values, or the text "true", as the docs say. Anything else counts as not true.
Where is alltrue used?
Often in a variable’s validation block, with a for expression that turns each item into a true or false.
Conclusion
alltrue(<LIST>) is true when every item is true, and also when the list is empty.
Additional Resources
OpenTofu® is a registered trademark of LF Projects, LLC. Other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by the OpenTofu project.
![Card titled The alltrue Function, labelled OpenTofu Functions, showing alltrue([true, false]) and the result false.](https://i0.wp.com/jd-bots.com/wp-content/uploads/2026/11/alltrue-function-opentofu-featured.webp?fit=728%2C410&ssl=1)