Terraform functions
Terraform has a number of built-in functions that you can utilize to create or transform expressions. One of the best ways to learn them is to use Terraform interactively using the terraform console
command. We introduced this command earlier to investigate the state interactively. Here is another way to use Terraform interactively and learn about functions:
$ terraform console > max(2,3) 3 > lower("HELLO WORLD") "hello world" > index(["apple", "orange", "banana"], "orange") 1 > formatdate("HH:mm",timestamp()) "01:32"
The general syntax for Terraform functions is function_name(argument_1, argument_2, …, argument_n)
. Terraform has a variety of built-in functions, including string, data, numeric, and filesystem functions. Please refer to the documentation at https://www.terraform.io/language/functions for a complete reference.