Challenge - 5 Problems
Terraform String Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
What is the output of this Terraform expression using join and split?
Given the Terraform expression:
What is the resulting string?
join(",", split("-", "a-b-c-d"))What is the resulting string?
Terraform
join(",", split("-", "a-b-c-d"))
Attempts:
2 left
💡 Hint
Think about how split breaks the string and how join combines the list.
✗ Incorrect
The split function breaks the string at each '-', producing ["a", "b", "c", "d"]. Then join combines these with commas, resulting in "a,b,c,d".
❓ Configuration
intermediate2:00remaining
What is the value of variable 'result' after this Terraform format call?
Consider this Terraform code:
What is the output value of 'result'?
variable "name" { default = "cloud" }
variable "count" { default = 3 }
output "result" {
value = format("%s-%d", var.name, var.count)
}What is the output value of 'result'?
Terraform
format("%s-%d", var.name, var.count)Attempts:
2 left
💡 Hint
Look at the order of arguments in format and their types.
✗ Incorrect
The format function replaces %s with the string var.name ('cloud') and %d with the integer var.count (3), producing 'cloud-3'.
🧠 Conceptual
advanced2:00remaining
Which option correctly splits a comma-separated string into a list in Terraform?
You have a string variable:
Which expression produces the list ["red", "green", "blue"]?
variable "csv" { default = "red,green,blue" }Which expression produces the list ["red", "green", "blue"]?
Attempts:
2 left
💡 Hint
Splitting uses the delimiter to break the string into parts.
✗ Incorrect
split(",", var.csv) breaks the string at commas, producing the list ["red", "green", "blue"].
❓ security
advanced2:00remaining
What is the risk of using format with user input without validation in Terraform?
If you use format("User: %s", var.user_input) directly in resource names, what could happen?
Attempts:
2 left
💡 Hint
Think about what happens if user input has spaces or special symbols.
✗ Incorrect
Terraform resource names must follow strict rules. If user input contains invalid characters, the resource creation will fail.
❓ Architecture
expert3:00remaining
Which Terraform expression produces a single string from a list with a custom separator and prefix?
Given a list variable:
Which expression produces the string "Items: one | two | three"?
variable "items" { default = ["one", "two", "three"] }Which expression produces the string "Items: one | two | three"?
Attempts:
2 left
💡 Hint
Use join to combine list elements, then format to add prefix.
✗ Incorrect
join(" | ", var.items) creates "one | two | three". Then format adds "Items: " prefix, resulting in "Items: one | two | three".