TA-002-P · Question #114
lookup retrieves the value of a single element from which of the below data type?
The correct answer is A. map. The lookup function in Terraform is specifically designed to retrieve the value of a single element from a map based on a provided key.
Question
lookup retrieves the value of a single element from which of the below data type?
Options
- Amap
- Bset
- Cstring
- Dlist
How the community answered
(40 responses)- A93% (37)
- C3% (1)
- D5% (2)
Why each option
The `lookup` function in Terraform is specifically designed to retrieve the value of a single element from a map based on a provided key.
The `lookup` function is used to retrieve the value associated with a specific key within a map, returning a default value if the key does not exist. Its primary purpose is key-value retrieval from map data structures.
`lookup` is not used for `set` data types; sets are unordered collections of unique values, typically accessed for membership or iteration.
`lookup` is not used for `string` data types; string manipulation functions are used for strings.
`lookup` is not used for `list` data types; elements in a list are typically accessed by their numeric index or using functions like `element`.
Concept tested: Terraform lookup function usage
Source: https://developer.hashicorp.com/terraform/language/functions/lookup
Topics
Community Discussion
No community discussion yet for this question.