Back to course

HCL Functions: Built-in Magic

Infrastructure as Code (Terraform & OpenTofu Mastery)

Manipulating Data

OpenTofu includes built-in functions to transform data. You can't write your own functions, but the ones provided are powerful.

  • upper("hello") -> "HELLO"
  • lookup({a="1", b="2"}, "a", "0") -> "1"
  • file("${path.module}/hello.txt") -> Reads the file content.

Try it out using the command tofu console to test functions in real-time.