Every Terraform function, searchable
Terraform’s configuration language (HCL) ships with a large library of built-in functions for transforming strings, collections, numbers, files, IP ranges and more. This reference lists each function with its signature, a description and a concrete example. Filter by category or search by name.
How it works
Terraform functions are pure: given the same inputs they always return the same output, and they run during plan/apply to compute values for locals, resource arguments and outputs. There are no user-defined functions — you compose the built-ins.
Functions are grouped by purpose. String functions (format, replace, substr) manipulate text. Collection functions (merge, flatten, lookup, distinct) reshape lists, sets and maps. Encoding functions (jsonencode, base64encode, yamlencode) serialise values for policies and APIs. Network functions (cidrsubnet, cidrhost) do subnet math. Filesystem functions (file, templatefile) read content from disk. The category filter in this tool mirrors these groups.
Read each entry as name(arguments) with the example showing a representative input and the resulting value. Combine functions freely, for example join(",", distinct(flatten(var.lists))).
Tips and examples
- Provide safe defaults instead of failing a plan:
locals {
region = coalesce(var.region, "eu-west-1")
tag = lookup(var.tags, "env", "dev")
}
- Build subnets programmatically across availability zones:
cidrsubnet("10.0.0.0/16", 8, count.index)
- Use
try(...)to gracefully handle expressions that might error, andjsonencodeto emit IAM or other JSON policy documents from native HCL objects. - Test any expression quickly in
terraform consolebefore wiring it into your configuration.