Skip to main content
coalesce(vals...) evaluates its arguments in order and returns the first one that is not null.

Signature

All arguments must have the same type.

Example

Pick the deployment region from multiple variable sources, falling back through a priority chain:
If --var target_region=eu-west-1 is passed, that value is used. If only default_region is set, that is used. Otherwise us-east-1 is the fallback.

Notes

  • coalesce skips null values. It does not skip empty strings, false, or 0.
  • If all arguments are null, coalesce returns an error.
  • coalesce works on scalar values. For picking the first non-empty list, use concat with compact.