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