-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f556ea1
commit b364510
Showing
1 changed file
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,28 @@ | ||
# Terraform Assertion | ||
A simple module that asserts (during planning) that a condition is true. | ||
A simple module that asserts that a condition is true. The assertion is checked during planning, unless the condition depends on a value that will only be known during apply. | ||
|
||
The module forces Terraform to fail if the condition is false by attempting to call a non-existant external command. It uses the error message in the command name so that the resulting Terraform failure message is descriptive (although it is slightly confusing in the format; see the example below). | ||
|
||
## Usage | ||
``` | ||
module "assertion_unix_only" { | ||
source = "Invicton-Labs/assertion/null" | ||
// The condition to ensure is TRUE | ||
// In this example, assert that the operating system uses forward slashes for path separators | ||
condition = dirname("/") == "/" | ||
// The error message to print out if the condition evaluates to FALSE | ||
error_message = "This Terraform configuration can only be run on Unix-based machines." | ||
} | ||
``` | ||
|
||
Output on Unix machines: | ||
``` | ||
No changes. Your infrastructure matches the configuration. | ||
``` | ||
|
||
Output on Windows machines: | ||
``` | ||
Error: can't find external program "ERROR: This Terraform configuration can only be run on Unix-based machines." | ||
``` |