Skip to content

Commit fd17247

Browse files
kierramarieAk-sky
andauthored
fix: added prefix input validation to solution (#329)
* fix: added prefix validation * fix: prefix validation update * fix: prefix validation * fix: better regex * fix: wrong prefix length --------- Co-authored-by: Akash Kumar <Ak-sky@users.noreply.github.com>
1 parent 8b7a1b5 commit fd17247

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

solutions/standard/variables.tf

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ variable "prefix" {
4545
type = string
4646
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."
4747
default = "dev"
48+
validation {
49+
condition = (var.prefix == null ? true :
50+
alltrue([
51+
can(regex("^[a-z]{0,1}[-a-z0-9]{0,14}[a-z0-9]{0,1}$", var.prefix)),
52+
length(regexall("^.*--.*", var.prefix)) == 0
53+
])
54+
)
55+
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."
56+
}
4857
}
4958

5059
########################################################################################################################

0 commit comments

Comments
 (0)