-
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.
Switch to integrated Terraform variable validation (#4)
- Loading branch information
1 parent
f6bba7b
commit b04ce2f
Showing
6 changed files
with
34 additions
and
34 deletions.
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
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
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,4 +1,14 @@ | ||
output "error_message" { | ||
description = "The value of the `error_message` input variable." | ||
value = var.error_message | ||
} | ||
|
||
output "condition" { | ||
description = "The value of the `condition` input variable." | ||
value = var.condition | ||
} | ||
|
||
output "checked" { | ||
description = "Whether the condition has been checked (used for assertion dependencies)." | ||
value = data.cloudinit_config.check.rendered == "" ? true : true | ||
value = var.condition == true ? true : true | ||
} |
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,9 +1,18 @@ | ||
variable "condition" { | ||
description = "The condition to ensure is `true`." | ||
type = bool | ||
} | ||
|
||
variable "error_message" { | ||
description = "The error message to display if the condition evaluates to `false`." | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "condition" { | ||
description = "The condition to ensure is `true`." | ||
type = bool | ||
validation { | ||
// We have to use var.error_message != null to force the evaluation to wait | ||
// until var.error_message is known. Otherwise, it can fail during the validation | ||
// phase but won't output the proper error message. | ||
// https://github.com/hashicorp/terraform/issues/35397 | ||
condition = var.error_message != null && var.condition == true | ||
error_message = var.error_message | ||
} | ||
} |
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,9 +1,3 @@ | ||
terraform { | ||
required_version = ">= 0.13.0" | ||
required_providers { | ||
cloudinit = { | ||
source = "hashicorp/cloudinit" | ||
version = ">= 2.3.1" | ||
} | ||
} | ||
required_version = ">= 1.9.0" | ||
} |