Challenge - 5 Problems
Terraform Collection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of length function on a list?
Given the Terraform expression
length(["apple", "banana", "cherry"]), what is the output?Terraform
length(["apple", "banana", "cherry"])
Attempts:
2 left
💡 Hint
Count the number of items inside the list.
✗ Incorrect
The length function returns the number of elements in the list. Here, there are three fruits, so the output is 3.
❓ query_result
intermediate2:00remaining
What does flatten do to nested lists?
What is the result of
flatten([[1, 2], [3, 4], [5]]) in Terraform?Terraform
flatten([[1, 2], [3, 4], [5]])
Attempts:
2 left
💡 Hint
Flatten removes one level of nested lists.
✗ Incorrect
The flatten function merges all inner lists into a single list, so the output is a flat list of all elements.
📝 Syntax
advanced2:00remaining
Which merge expression correctly combines two maps?
Select the Terraform expression that correctly merges two maps
{a = 1, b = 2} and {b = 3, c = 4} with the second map overriding keys from the first.Attempts:
2 left
💡 Hint
Use merge with two separate map arguments.
✗ Incorrect
The merge function takes multiple maps as separate arguments and combines them. Option D is the correct syntax.
❓ optimization
advanced2:00remaining
Optimizing nested flatten calls
Given a nested list
[[[1], [2, 3]], [[4]]], which expression efficiently flattens it into a single list [1, 2, 3, 4]?Attempts:
2 left
💡 Hint
Use flatten twice to remove two levels of nesting.
✗ Incorrect
The list has three levels of nesting. Using flatten twice removes two levels, resulting in a flat list.
🧠 Conceptual
expert2:00remaining
What is the length of a merged map?
If you merge two maps
{x = 10, y = 20} and {y = 30, z = 40}, what is the length of the resulting map?Terraform
length(merge({x = 10, y = 20}, {y = 30, z = 40}))Attempts:
2 left
💡 Hint
Keys that appear in both maps are overridden, not duplicated.
✗ Incorrect
The merged map has keys x, y, and z. The key y from the second map overrides the first. So total keys are 3.