Skip to content

Commit f21d0e8

Browse files
committed
website: Update docs for check rule error messages
1 parent 45d0c04 commit f21d0e8

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

website/docs/language/expressions/preconditions-postconditions.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,15 @@ Error: Resource postcondition failed
335335
The selected AMI must be tagged with the Component value "nomad-server".
336336
```
337337

338-
The `error_message` argument must always be a literal string, and should
339-
typically be written as a full sentence in a style similar to Terraform's own
340-
error messages. Terraform will show the given message alongside the name
341-
of the resource that detected the problem and any outside values used as part
342-
of the condition expression.
338+
The `error_message` argument can be any expression which evaluates to a string.
339+
This includes literal strings, heredocs, and template expressions. Multi-line
340+
error messages are supported, and lines with leading whitespace will not be
341+
word wrapped.
342+
343+
Error message should typically be written as one or more full sentences in a
344+
style similar to Terraform's own error messages. Terraform will show the given
345+
message alongside the name of the resource that detected the problem and any
346+
outside values used as part of the condition expression.
343347

344348
## Preconditions or Postconditions?
345349

website/docs/language/values/variables.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,13 @@ variable "image_id" {
198198
```
199199

200200
If `condition` evaluates to `false`, Terraform will produce an error message
201-
that includes the sentences given in `error_message`. The error message string
201+
that includes the result of the `error_message` expression. The error message
202202
should be at least one full sentence explaining the constraint that failed,
203203
using a sentence structure similar to the above examples.
204204

205+
Error messages can be literal strings, heredocs, or template expressions. The
206+
only valid reference in an error message is the variable under validation.
207+
205208
Multiple `validation` blocks can be declared in which case error messages
206209
will be returned for _all_ failed conditions.
207210

0 commit comments

Comments
 (0)