Challenge - 5 Problems
Terraform Type Conversion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Understanding Terraform type conversion with tostring()
What is the output of the following Terraform expression?
tostring(12345)
Terraform
tostring(12345)Attempts:
2 left
💡 Hint
tostring() converts numbers to strings.
✗ Incorrect
The tostring() function converts a number to its string representation. So 12345 becomes "12345".
❓ Configuration
intermediate1:30remaining
Using tonumber() with a string in Terraform
What is the result of this Terraform expression?
tonumber("3.14")Terraform
tonumber("3.14")Attempts:
2 left
💡 Hint
tonumber() converts strings that look like numbers into numbers.
✗ Incorrect
The tonumber() function converts the string "3.14" to the numeric value 3.14.
❓ service_behavior
advanced2:00remaining
Behavior of tolist() with a map in Terraform
What happens when you apply tolist() to this map in Terraform?
tolist({a = 1, b = 2, c = 3})Terraform
tolist({a = 1, b = 2, c = 3})Attempts:
2 left
💡 Hint
tolist() extracts the values from the map in order.
✗ Incorrect
tolist() converts the map values into a list of values, ignoring keys. The order is consistent but not guaranteed to be sorted.
❓ Architecture
advanced2:00remaining
Converting a list of strings to a set in Terraform
Given this list:
Which Terraform function call produces a set with unique items?
["apple", "banana", "apple", "orange"]
Which Terraform function call produces a set with unique items?
Terraform
["apple", "banana", "apple", "orange"]
Attempts:
2 left
💡 Hint
toset() removes duplicates and creates a set.
✗ Incorrect
toset() converts a list to a set, removing duplicates. tomap() expects key-value pairs, tonumber() expects a string or number, tolist() returns the list as is.
❓ security
expert2:30remaining
Impact of incorrect type conversion on Terraform resource behavior
If a Terraform variable expects a number but receives a string without conversion, what is the likely outcome during plan or apply?
Attempts:
2 left
💡 Hint
Terraform enforces strict type checking for variables.
✗ Incorrect
Terraform validates variable types strictly. Passing a string where a number is expected causes a type mismatch error and halts the plan or apply.