From bc7333c5b0e61b7bc4db7efd8dad13d4e44ba5c8 Mon Sep 17 00:00:00 2001 From: Adam J Bravo <90470462+atombravo@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:29:45 -0400 Subject: [PATCH 1/2] Type conversion with equality operator Adding a note and link to the documentation for the equality operator, as a notable exception to the automatic type conversion rule. --- website/docs/language/expressions/types.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/docs/language/expressions/types.mdx b/website/docs/language/expressions/types.mdx index 078235744b..0d49007bb4 100644 --- a/website/docs/language/expressions/types.mdx +++ b/website/docs/language/expressions/types.mdx @@ -137,7 +137,8 @@ expression must produce a value of that type. Where possible, Terraform automatically converts values from one type to another in order to produce the expected type. If this isn't possible, Terraform will produce a type mismatch error and you must update the configuration with a -more suitable expression. +more suitable expression. Automatic type conversion does not occur when using +the [equality operator](/language/expressions/operators.mdx#equality-operators). Terraform automatically converts number and bool values to strings when needed. It also converts strings to numbers or bools, as long as the string contains a @@ -146,3 +147,4 @@ valid representation of a number or bool value. * `true` converts to `"true"`, and vice-versa * `false` converts to `"false"`, and vice-versa * `15` converts to `"15"`, and vice-versa + From d1d48f9aa520209e90a34030b68b06f8ba9889ab Mon Sep 17 00:00:00 2001 From: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> Date: Mon, 19 May 2025 13:00:04 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Radek Simko --- website/docs/language/expressions/types.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/language/expressions/types.mdx b/website/docs/language/expressions/types.mdx index a93fd7abc6..5a9d86f951 100644 --- a/website/docs/language/expressions/types.mdx +++ b/website/docs/language/expressions/types.mdx @@ -173,10 +173,10 @@ child modules. In these cases, the argument has an expected type and the given expression must produce a value of that type. Where possible, Terraform automatically converts values from one type to -another in order to produce the expected type. If this isn't possible, Terraform -will produce a type mismatch error and you must update the configuration with a -more suitable expression. Automatic type conversion does not occur when using -the [equality operator](/language/expressions/operators.mdx#equality-operators). +another to produce the expected type. If this conversion is impossible, Terraform +produces a type mismatch error and you must update the configuration with a +more suitable expression. Automatic type conversion does not occur when using +the [equality operator](/terraform/language/expressions/operators.mdx#equality-operators). Terraform automatically converts number and bool values to strings when needed. It also converts strings to numbers or bools, as long as the string contains a