diff --git a/solutions/fully-configurable/variables.tf b/solutions/fully-configurable/variables.tf index c261c807..148e6bb7 100644 --- a/solutions/fully-configurable/variables.tf +++ b/solutions/fully-configurable/variables.tf @@ -20,24 +20,9 @@ variable "prefix" { nullable = true description = "The prefix to be added to all resources created by this solution. To skip using a prefix, set this value to null or an empty string. The prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It should not exceed 16 characters, must not end with a hyphen('-'), and can not contain consecutive hyphens ('--'). Example: prod-0205-cos. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)." - validation { - # - null and empty string is allowed - # - Must not contain consecutive hyphens (--): length(regexall("--", var.prefix)) == 0 - # - Starts with a lowercase letter: [a-z] - # - Contains only lowercase letters (a–z), digits (0–9), and hyphens (-) - # - Must not end with a hyphen (-): [a-z0-9] - condition = (var.prefix == null || var.prefix == "" ? true : - alltrue([ - can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)), - length(regexall("--", var.prefix)) == 0 - ]) - ) - error_message = "Prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It must not end with a hyphen('-'), and cannot contain consecutive hyphens ('--')." - } - validation { # must not exceed 16 characters in length - condition = length(var.prefix) <= 16 + condition = var.prefix == null || var.prefix == "" ? true : length(var.prefix) <= 16 error_message = "Prefix must not exceed 16 characters." } } diff --git a/solutions/security-enforced/variables.tf b/solutions/security-enforced/variables.tf index eb9a5a72..a10fd4cf 100644 --- a/solutions/security-enforced/variables.tf +++ b/solutions/security-enforced/variables.tf @@ -20,24 +20,9 @@ variable "prefix" { nullable = true description = "The prefix to be added to all resources created by this solution. To skip using a prefix, set this value to null or an empty string. The prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It should not exceed 16 characters, must not end with a hyphen('-'), and can not contain consecutive hyphens ('--'). Example: prod-0205-cos. [Learn more](https://terraform-ibm-modules.github.io/documentation/#/prefix.md)." - validation { - # - null and empty string is allowed - # - Must not contain consecutive hyphens (--): length(regexall("--", var.prefix)) == 0 - # - Starts with a lowercase letter: [a-z] - # - Contains only lowercase letters (a–z), digits (0–9), and hyphens (-) - # - Must not end with a hyphen (-): [a-z0-9] - condition = (var.prefix == null || var.prefix == "" ? true : - alltrue([ - can(regex("^[a-z][-a-z0-9]*[a-z0-9]$", var.prefix)), - length(regexall("--", var.prefix)) == 0 - ]) - ) - error_message = "Prefix must begin with a lowercase letter and may contain only lowercase letters, digits, and hyphens '-'. It must not end with a hyphen('-'), and cannot contain consecutive hyphens ('--')." - } - validation { # must not exceed 16 characters in length - condition = length(var.prefix) <= 16 + condition = var.prefix == null || var.prefix == "" ? true : length(var.prefix) <= 16 error_message = "Prefix must not exceed 16 characters." } }