From 2361c5dc98b896b46c6b6c6de4d5139a30b320e2 Mon Sep 17 00:00:00 2001 From: Zach Himsel Date: Tue, 28 Nov 2023 11:56:52 -0500 Subject: [PATCH] Document negative host numbers for cidrhost() This feature was introduced in https://github.com/hashicorp/terraform/pull/13765 (and documented there), but it seems that its documentation was not carried over when the docs were reorganized. --- website/docs/language/functions/cidrhost.mdx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/website/docs/language/functions/cidrhost.mdx b/website/docs/language/functions/cidrhost.mdx index 68cde0a2f7..83b3762326 100644 --- a/website/docs/language/functions/cidrhost.mdx +++ b/website/docs/language/functions/cidrhost.mdx @@ -19,7 +19,11 @@ cidrhost(prefix, hostnum) `hostnum` is a whole number that can be represented as a binary integer with no more than the number of digits remaining in the address after the given -prefix. For more details on how this function interprets CIDR prefixes and +prefix. If `hostnum` is negative, the count starts from the end of the range. +For example, `cidrhost("10.0.0.0/8", 2)` returns `10.0.0.2` and +`cidrhost("10.0.0.0/8", -2)` returns `10.255.255.254`. + +For more details on how this function interprets CIDR prefixes and populates host numbers, see the worked example for [`cidrsubnet`](/terraform/language/functions/cidrsubnet).