built-in function
One of Terraform's fixed set of functions, such as lower(), join() or jsonencode(), that transform values inside expressions.
In more detail
You cannot write your own functions; you combine the built-in ones. They are deterministic and only transform values in memory, so they never change infrastructure. Read nested calls from the inside out, asking what type each one returns.
Examples
lower(trimspace(" Ada ")) # "ada"length(var.names)Related terms
- Terraform expression — Anything that produces a value on the right of an equals sign: a literal, a reference, a function call, a for expression or a conditional.
- jsonencode — The function that turns a Terraform value, such as a map or list, into a string of JSON text.
- merge() — The function that combines several maps into one, with keys in later maps winning over earlier ones.
- format() — The function that builds a string from a template with placeholders such as %s for text and %02d for a zero-padded number.
- join() — The function that glues a list of strings into one string with a separator between each.
- try() — The function that returns the first of its arguments that evaluates without an error, used to supply a fallback.
Taught in
- Parameterising With Input Variables — Infrastructure as Code with Terraform
- Functions And Expressions In HCL — Infrastructure as Code with Terraform
- Querying Existing Infrastructure With Data Sources — Infrastructure as Code with Terraform
- Expressions And Functions: Making Configuration Compute — HashiCorp Terraform Associate (004) Exam Prep