Back to Packer

`lookup` Function

website/content/docs/templates/hcl_templates/functions/collection/lookup.mdx

1.15.31.0 KB
Original Source

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

[!IMPORTANT]
Documentation Update: Product documentation previously located in /website has moved to the hashicorp/web-unified-docs repository, where all product documentation is now centralized. Please make contributions directly to web-unified-docs, since changes to /website in this repository will not appear on developer.hashicorp.com. ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

lookup Function

lookup retrieves the value of a single element from a map, given its key. If the given key does not exist, the given default value is returned instead.

hcl
lookup(map, key, default)

Examples

shell-session
> lookup({a="ay", b="bee"}, "a", "what?")
ay
> lookup({a="ay", b="bee"}, "c", "what?")
what?
  • element retrieves a value from a list given its index.