String Functions
The following section will cover the most common string
functions supported by Terraform 1.5.x. string
functions are primarily used for formatting the input values for different requirements and using the result in the subsequent workflow. The examples used in the section will be available with the filename 2. string-functions.txt
in the GitHub link provided at the start of this chapter. You just need to take the specific command and try it with your sample inputs in the Terraform console terminal.
The split() Function
The split()
function will split the input string in all occurrences where the separator
character is present. The resulting value will be of the list
type, and if we are using the output values to initialize any variable, the variable should be of the list
data type.
Here is the syntax:
split(separator-char, input-string)
Some examples are as follows:
$ split("-", "test-dev-prod")
> tolist([
...