Terraform Functions and Conditional Expressions
Links: 113 Terraform Index
Functions¶
- Some of the common functions are
file
: read data from a filelength
: determine the number of elements in a list or maptoset
: convert a list to a set
- We can test functions using an interactive console.
- We can use the terraform console using
terraform console
- Terraform console loads the state associated to the configuration directory by default.
- It also loads variables in the configuration files.
- We can use the terraform console using
- Numeric functions
- Expansion is needed when using variables.
- String functions
split
is used to split a string based on the separator. It returns a list.join
is used to convert a list to a string.
- List functions
contains
is case sensitive
- Map functions
- We can provide a default argument to the
lookup
function
Conditional Expressions¶
- Assigning value to a variable based on condition
- Generating a random password of atleast 8 characters where length of password comes from the user.
Last updated: 2023-01-14