github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/lookup.mdx (about)

     1  ---
     2  page_title: lookup - Functions - Configuration Language
     3  description: The lookup function retrieves an element value from a map given its key.
     4  ---
     5  
     6  # `lookup` Function
     7  
     8  `lookup` retrieves the value of a single element from a map, given its key.
     9  If the given key does not exist, the given default value is returned instead.
    10  
    11  ```
    12  lookup(map, key, default)
    13  ```
    14  
    15  -> For historical reasons, the `default` parameter is actually optional. However,
    16  omitting `default` is deprecated since v0.7 because that would then be
    17  equivalent to the native index syntax, `map[key]`.
    18  
    19  ## Examples
    20  
    21  ```
    22  > lookup({a="ay", b="bee"}, "a", "what?")
    23  ay
    24  > lookup({a="ay", b="bee"}, "c", "what?")
    25  what?
    26  ```
    27  
    28  ## Related Functions
    29  
    30  * [`element`](/language/functions/element) retrieves a value from a _list_ given its _index_.