0
0
Terraformcloud~5 mins

String functions (join, split, format) in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Terraform function join do?
The join function combines a list of strings into one string, using a specified separator between each element.
Click to reveal answer
beginner
How does the split function work in Terraform?
The split function breaks a single string into a list of strings, using a specified separator to decide where to split.
Click to reveal answer
beginner
Explain the purpose of the format function in Terraform.
The format function creates a formatted string by inserting values into placeholders inside a template string, similar to filling blanks in a sentence.
Click to reveal answer
beginner
Example: What is the result of join(",", ["apple", "banana", "cherry"])?
The result is the string "apple,banana,cherry", which joins the list elements with commas.
Click to reveal answer
beginner
Example: What does split(",", "red,green,blue") return?
It returns the list ["red", "green", "blue"] by splitting the string at each comma.
Click to reveal answer
Which Terraform function would you use to combine a list of strings into one string?
Asplit
Bjoin
Cformat
Dconcat
What does the split function return when given a string and a separator?
AA list of strings
BA number
CA single string
DA boolean
How does the format function work in Terraform?
AIt splits strings into lists
BIt joins lists into strings
CIt inserts values into a template string
DIt converts strings to numbers
What is the output of join("-", ["a", "b", "c"])?
A"a,b,c"
B"abc"
C["a", "b", "c"]
D"a-b-c"
If you run split(":", "key:value"), what do you get?
A["key", "value"]
B"key:value"
C"key"
D[":", "key", "value"]
Describe how you would use Terraform string functions to convert a list of strings into a single comma-separated string.
Think about combining list items with a character between them.
You got /4 concepts.
    Explain how the format function helps in creating dynamic strings in Terraform configurations.
    Imagine writing a sentence where you fill in names or numbers dynamically.
    You got /4 concepts.