Skill 4.5.3

Built-in functions and terraform console

Key Concepts

Functions are called as name(arguments). They are grouped into numeric (min, max, ceil), string (format, join, split, replace, lower, trimspace), collection (length, lookup, merge, concat, flatten, keys, values, contains, zipmap, element), encoding (jsonencode, yamlencode, base64encode), filesystem (file, templatefile, fileset), date and time (timestamp, formatdate), hash and crypto, IP network (cidrsubnet, cidrhost) and type conversion (tolist, toset, try, can) functions.

Terraform does not support user-defined functions; providers can add their own functions, called as provider::NAME::FUNCTION(). terraform console opens an interactive prompt where you can evaluate expressions and functions, with access to the current state, variables and locals, which makes it the quickest way to test an expression.