nerdexam
HashiCorp

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.

Read, generate, and modify configuration

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)
  • A
    93% (37)
  • C
    3% (1)
  • D
    5% (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.

AmapCorrect

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.

Bset

`lookup` is not used for `set` data types; sets are unordered collections of unique values, typically accessed for membership or iteration.

Cstring

`lookup` is not used for `string` data types; string manipulation functions are used for strings.

Dlist

`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

#Terraform functions#lookup function#Terraform data types#map data type

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice