Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit 9bee29a

Browse files
authored
fix: added validation to the DA prefix input. Prefix must begin with a lowercase letter, contain only lowercase letters, numbers, and - characters. Prefix must end with a lowercase letter or number and be 16 or fewer characters. (#224)
1 parent 76ab4ae commit 9bee29a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

solutions/instances/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ variable "prefix" {
3030
type = string
3131
description = "The prefix to add to all resources that this solution creates. To not use any prefix value, you can set this value to `null` or an empty string."
3232
default = "dev"
33+
validation {
34+
condition = (var.prefix == null ? true :
35+
alltrue([
36+
can(regex("^[a-z]{0,1}[-a-z0-9]{0,14}[a-z0-9]{0,1}$", var.prefix)),
37+
length(regexall("^.*--.*", var.prefix)) == 0
38+
])
39+
)
40+
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."
41+
}
3342
}
3443

3544
variable "provider_visibility" {

tests/pr_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestRunUpgradeInstances(t *testing.T) {
9292
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
9393
Testing: t,
9494
TerraformDir: instanceFlavorDir,
95-
Prefix: "scc-ins-upg",
95+
Prefix: "scc-upg",
9696
})
9797

9898
options.TerraformVars = map[string]interface{}{

0 commit comments

Comments
 (0)