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

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

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

Explanation:
Key-value pairs are modeled with a map in Terraform. A map associates each key with a value, letting you look up values by their name, like environment = "prod" or region = "us-east-1". Lists and tuples are ordered sequences indexed by position and don’t provide named keys, so they can’t represent arbitrary key/value pairs. Sets are unordered and contain unique elements without any key, so they also can’t store key/value pairs. Because you need a structure where each item has a name (key) and a value, a map is the correct choice.

Key-value pairs are modeled with a map in Terraform. A map associates each key with a value, letting you look up values by their name, like environment = "prod" or region = "us-east-1". Lists and tuples are ordered sequences indexed by position and don’t provide named keys, so they can’t represent arbitrary key/value pairs. Sets are unordered and contain unique elements without any key, so they also can’t store key/value pairs. Because you need a structure where each item has a name (key) and a value, a map is the correct choice.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy