2018-05-12 18:39:29 +02:00
|
|
|
---
|
2021-12-15 03:41:17 +01:00
|
|
|
page_title: list - Functions - Configuration Language
|
|
|
|
description: The list function constructs a list from some given elements.
|
2018-05-12 18:39:29 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# `list` Function
|
|
|
|
|
2020-11-04 22:18:44 +01:00
|
|
|
The `list` function is no longer available. Prior to Terraform v0.12 it was
|
|
|
|
the only available syntax for writing a literal list inside an expression,
|
|
|
|
but Terraform v0.12 introduced a new first-class syntax.
|
2018-05-12 18:39:29 +02:00
|
|
|
|
2020-11-04 22:18:44 +01:00
|
|
|
To update an expression like `list(a, b, c)`, write the following instead:
|
2018-05-12 18:39:29 +02:00
|
|
|
|
|
|
|
```
|
2020-11-04 22:18:44 +01:00
|
|
|
tolist([a, b, c])
|
2018-05-12 18:39:29 +02:00
|
|
|
```
|
|
|
|
|
2020-11-04 22:18:44 +01:00
|
|
|
The `[ ... ]` brackets construct a tuple value, and then the `tolist` function
|
|
|
|
then converts it to a list. For more information on the value types in the
|
2021-12-15 03:41:17 +01:00
|
|
|
Terraform language, see [Type Constraints](/language/expressions/types).
|
2019-01-17 18:11:48 +01:00
|
|
|
|
|
|
|
## Related Functions
|
|
|
|
|
2021-12-15 03:41:17 +01:00
|
|
|
* [`concat`](/language/functions/concat) produces a new list by concatenating together the
|
2020-11-04 22:18:44 +01:00
|
|
|
elements from other lists.
|
2021-12-15 03:41:17 +01:00
|
|
|
* [`tolist`](/language/functions/tolist) converts a set or tuple value to a list.
|