nerdexam
HashiCorp

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…

Read, generate, and modify configuration

Question

Which Terraform collection type should you use to store key/value pairs?

Options

  • Aset
  • Btuple
  • Clist
  • Dmap

How the community answered

(25 responses)
  • B
    4% (1)
  • C
    4% (1)
  • D
    92% (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

#Terraform data types#Collection types#Maps#Configuration syntax

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice