Created
September 10, 2020 13:35
-
-
Save straubt1/e8fd8716e1e9133884005cc6c7cac8e4 to your computer and use it in GitHub Desktop.
Terraform 0.13 Variable Validation Rule
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
terraform { | |
required_version = "~> 0.13.0" | |
} | |
variable "environment_name" { | |
description = "The environment name." | |
type = string | |
validation { | |
condition = contains(["develop", "stage", "production"], var.environment_name) | |
error_message = "The environment_name value is not allowed. [\"develop\", \"stage\", \"production\"]." | |
} | |
} | |
# Notes: | |
# `condition` The condition for variable "environment_name" can only refer to the variable itself, using var.environment_name. | |
# `error_message` Validation error message must be at least one full English sentence starting with an uppercase letter and ending with a period or question mark. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment