mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-01-04 01:01:25 -05:00
* funcs/coalesce: return the first non-null, non-empty element from a sequence. The go-cty coalesce function, which was originally used here, returns the first non-null element from a sequence. Terraform 0.11's coalesce, however, returns the first non-empty string from a list of strings. This new coalesce function aims to preserve terraform's documented functionality while adding support for additional argument types. The tests include those in go-cty and adapted tests from the 0.11 version of coalesce. * website/docs: update coalesce function document
969 B
969 B
layout, page_title, sidebar_current, description
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| functions | coalesce - Functions - Configuration Language | docs-funcs-collection-coalesce-x | The coalesce function takes any number of arguments and returns the first one that isn't null nor empty. |
coalesce Function
-> Note: This page is about Terraform 0.12 and later. For Terraform 0.11 and earlier, see 0.11 Configuration Language: Interpolation Syntax.
coalesce takes any number of arguments and returns the first one
that isn't null or an empty string.
Examples
> coalesce("a", "b")
a
> coalesce("", "b")
b
> coalesce(1,2)
1
To perform the coalesce operation with a list of strings, use the ...
symbol to expand the list as arguments:
> coalesce(["", "b"]...)
b
Related Functions
coalescelistperforms a similar operation with list arguments rather than individual arguments.