Created
October 6, 2022 21:08
-
-
Save guillermo-musumeci/1953fa6a394ce1f45efaeab2b3b10646 to your computer and use it in GitHub Desktop.
Variable Validation in Terraform
This file contains hidden or 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
| variable "storage_account_name" { | |
| type = string | |
| description = "Azure Storage Account Name (3 to 24 characters, lowercase letters and numbers only)" | |
| validation { | |
| condition = length(var.storage_account_name) >= 3 && length(var.storage_account_name) <= 24 | |
| error_message = "The storage_account_name variable name must be 3-24 characters in length" | |
| } | |
| validation { | |
| condition = can(regex("^[0-9A-Za-z]+$", var.storage_account_name)) | |
| error_message = "The storage account name variable must have letters and numbers only" | |
| } | |
| validation { | |
| condition = lower(var.storage_account_name) == var.storage_account_name | |
| error_message = "The storage account name value must be in all lowercase" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment