From a56264b7928dde8662444a9c932caf3d97367597 Mon Sep 17 00:00:00 2001 From: Robert de Bock Date: Tue, 13 May 2025 16:02:42 +0200 Subject: [PATCH] Emphasise "first". (#31653) From the documentation, I could not make up of only the index of the first occurrence is returned. By some local testing, I've verified this. --- website/docs/language/functions/index_function.mdx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/website/docs/language/functions/index_function.mdx b/website/docs/language/functions/index_function.mdx index aae7015780..0839e0cbbf 100644 --- a/website/docs/language/functions/index_function.mdx +++ b/website/docs/language/functions/index_function.mdx @@ -5,7 +5,7 @@ description: The index function finds the element index for a given value in a l # `index` Function -`index` finds the element index for a given value in a list. +`index` finds the first element index for a given value in a list. ```hcl index(list, value) @@ -21,6 +21,13 @@ value is not present in the list. 1 ``` +In this example, the index of the first occurence of `"two"` is returned. + +``` +> index(["one", "two", "two"], "two") +1 +``` + ## Related Functions * [`element`](/terraform/language/functions/element) retrieves a particular element from a list given