Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added prefix validation #329

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
9 changes: 9 additions & 0 deletions solutions/standard/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ variable "prefix" {
type = string
description = "(Optional) Prefix to add to all resources created by this solution. To not use any prefix value, you can set this value to `null` or an empty string."
default = "dev"
validation {
condition = (var.prefix == null ? true :
alltrue([
can(regex("^[a-z]{0,1}[-a-z0-9]{0,11}[a-z0-9]{0,1}$", var.prefix)),
length(regexall("^.*--.*", var.prefix)) == 0
])
)
error_message = "Prefix must begin with a lowercase letter, contain only lowercase letters, numbers, and - characters. Prefixes must end with a lowercase letter or number and be 16 or fewer characters."
}
}

########################################################################################################################
Expand Down