TA-002-P · Question #362
Which Terraform collection type should you use to store key/value pairs?
The correct answer is D. map. In Terraform, a map is the correct collection type for storing key/value pairs, where keys are strings and all values share the same type (e.g., map(string)). A list is an ordered sequence of values of the same type. A set is an unordered collection of unique values. A tuple is…
Question
Which Terraform collection type should you use to store key/value pairs?
Options
- Aset
- Btuple
- Clist
- Dmap
How the community answered
(25 responses)- B4% (1)
- C4% (1)
- D92% (23)
Explanation
In Terraform, a map is the correct collection type for storing key/value pairs, where keys are strings and all values share the same type (e.g., map(string)). A list is an ordered sequence of values of the same type. A set is an unordered collection of unique values. A tuple is an ordered sequence where elements can have different types. When you need to look up values by a named key, always use map. Answer D is correct.
Topics
Community Discussion
No community discussion yet for this question.