website: Update docs for check rule error messages

This commit is contained in:
Alisdair McDiarmid 2022-02-08 10:42:50 -05:00
parent 45d0c04707
commit f21d0e8bf6
2 changed files with 13 additions and 6 deletions

View File

@ -335,11 +335,15 @@ Error: Resource postcondition failed
The selected AMI must be tagged with the Component value "nomad-server". The selected AMI must be tagged with the Component value "nomad-server".
``` ```
The `error_message` argument must always be a literal string, and should The `error_message` argument can be any expression which evaluates to a string.
typically be written as a full sentence in a style similar to Terraform's own This includes literal strings, heredocs, and template expressions. Multi-line
error messages. Terraform will show the given message alongside the name error messages are supported, and lines with leading whitespace will not be
of the resource that detected the problem and any outside values used as part word wrapped.
of the condition expression.
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? ## Preconditions or Postconditions?

View File

@ -198,10 +198,13 @@ variable "image_id" {
``` ```
If `condition` evaluates to `false`, Terraform will produce an error message 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, should be at least one full sentence explaining the constraint that failed,
using a sentence structure similar to the above examples. 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 Multiple `validation` blocks can be declared in which case error messages
will be returned for _all_ failed conditions. will be returned for _all_ failed conditions.