github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/hcl2/functions/collection/lookup.mdx (about)

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