Functions in waypoint.hcl
Warning
This content is part of the legacy version of Waypoint that is no longer actively maintained. For additional information on the new vision of Waypoint, check out this blog post and the HCP Waypoint documentation.
The waypoint.hcl
file uses HCL which
is able to call predefined functions. Functions enable Waypoint configurations
to represent complex configurations using programming techniques.
Most functions can be used anywhere in the Waypoint configuration file. Some functions are context-specific and are only valid when called from the correct locations. Function documentation pages may use placement tables to document where functions are valid. If a placement table is not present for a function, it is safe to assume that it can be used anywhere.
Calling Functions
Function usage is similar to many mainstream programming languages such as Javascript, Ruby, or Python. Functions can be called directly and assigned to values:
Functions can be composed:
Functions arguments can be any expressions: variables, mathematical operations, etc.:
Functions can be used as part of string interpolations. Regardless of the return value HCL will attempt to coerce it into a string:
Custom Functions
Waypoint does not support custom defined functions.
Use with variables
HCL functions are often especially useful when combined with hcl variables. For example, to include the base64 encoded contents of a file in your app's source project, you can use:
For a complete list of variables, see variables