diff --git a/website/docs/language/expressions/preconditions-postconditions.mdx b/website/docs/language/expressions/preconditions-postconditions.mdx index 1aebff3b7..635cb1b63 100644 --- a/website/docs/language/expressions/preconditions-postconditions.mdx +++ b/website/docs/language/expressions/preconditions-postconditions.mdx @@ -335,11 +335,15 @@ Error: Resource postcondition failed The selected AMI must be tagged with the Component value "nomad-server". ``` -The `error_message` argument must always be a literal string, and should -typically be written as a full sentence in a style similar to Terraform's own -error messages. Terraform will show the given message alongside the name -of the resource that detected the problem and any outside values used as part -of the condition expression. +The `error_message` argument can be any expression which evaluates to a string. +This includes literal strings, heredocs, and template expressions. Multi-line +error messages are supported, and lines with leading whitespace will not be +word wrapped. + +Error message should typically be written as one or more full sentences in a +style similar to Terraform's own error messages. Terraform will show the given +message alongside the name of the resource that detected the problem and any +outside values used as part of the condition expression. ## Preconditions or Postconditions? diff --git a/website/docs/language/values/variables.mdx b/website/docs/language/values/variables.mdx index 4bfe6e053..434c88a24 100644 --- a/website/docs/language/values/variables.mdx +++ b/website/docs/language/values/variables.mdx @@ -198,10 +198,13 @@ variable "image_id" { ``` If `condition` evaluates to `false`, Terraform will produce an error message -that includes the sentences given in `error_message`. The error message string +that includes the result of the `error_message` expression. The error message should be at least one full sentence explaining the constraint that failed, using a sentence structure similar to the above examples. +Error messages can be literal strings, heredocs, or template expressions. The +only valid reference in an error message is the variable under validation. + Multiple `validation` blocks can be declared in which case error messages will be returned for _all_ failed conditions.