Skip to content

Commit

Permalink
website: Update docs for check rule error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
alisdair committed Mar 4, 2022
1 parent 45d0c04 commit f21d0e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Expand Up @@ -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?

Expand Down
5 changes: 4 additions & 1 deletion website/docs/language/values/variables.mdx
Expand Up @@ -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.

Expand Down

0 comments on commit f21d0e8

Please sign in to comment.