github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/collection/lookup.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: lookup - Functions - Configuration Language
     4  description: The lookup function retrieves an element value from a map given its key.
     5  ---
     6  
     7  # `lookup` Function
     8  
     9  `lookup` retrieves the value of a single element from a map, given its key.
    10  If the given key does not exist, a the given default value is returned instead.
    11  
    12  ```hcl
    13  lookup(map, key, default)
    14  ```
    15  
    16  ## Examples
    17  
    18  ```shell-session
    19  > lookup({a="ay", b="bee"}, "a", "what?")
    20  ay
    21  > lookup({a="ay", b="bee"}, "c", "what?")
    22  what?
    23  ```
    24  
    25  ## Related Functions
    26  
    27  - [`element`](/docs/job-specification/hcl2/functions/collection/element) retrieves a value from a _list_ given its _index_.