mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-08 15:13:56 -06:00
provider/aws: improve redshift cluster validation (#12313)
* provider/aws: improve redshift cluster validation * aws/provider: redshift cluster mixed case name should be an invalid name
This commit is contained in:
parent
c5da896d22
commit
2cfe385653
@ -863,9 +863,9 @@ func validateRedshiftClusterIdentifier(v interface{}, k string) (ws []string, er
|
||||
|
||||
func validateRedshiftClusterDbName(v interface{}, k string) (ws []string, errors []error) {
|
||||
value := v.(string)
|
||||
if !regexp.MustCompile(`^[0-9A-Za-z_$]+$`).MatchString(value) {
|
||||
if !regexp.MustCompile(`^[0-9a-z_$]+$`).MatchString(value) {
|
||||
errors = append(errors, fmt.Errorf(
|
||||
"only alphanumeric characters, underscores, and dollar signs are allowed in %q", k))
|
||||
"only lowercase alphanumeric characters, underscores, and dollar signs are allowed in %q", k))
|
||||
}
|
||||
if !regexp.MustCompile(`^[a-zA-Z_]`).MatchString(value) {
|
||||
errors = append(errors, fmt.Errorf(
|
||||
@ -931,6 +931,10 @@ func validateRedshiftClusterMasterPassword(v interface{}, k string) (ws []string
|
||||
errors = append(errors, fmt.Errorf(
|
||||
"%q must contain at least one number", k))
|
||||
}
|
||||
if !regexp.MustCompile(`^[^\@\/'" ]*$`).MatchString(value) {
|
||||
errors = append(errors, fmt.Errorf(
|
||||
"%q cannot contain [/@\"' ]", k))
|
||||
}
|
||||
if len(value) < 8 {
|
||||
errors = append(errors, fmt.Errorf("%q must be at least 8 characters", k))
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ func TestValidateRedshiftClusterDbName(t *testing.T) {
|
||||
"testdbname",
|
||||
"test_dbname",
|
||||
"testdbname123",
|
||||
"TestDBname",
|
||||
"testdbname$hashicorp",
|
||||
"_dbname",
|
||||
}
|
||||
@ -44,6 +43,7 @@ func TestValidateRedshiftClusterDbName(t *testing.T) {
|
||||
"slash-at-the-end/",
|
||||
"",
|
||||
randomString(100),
|
||||
"TestDBname",
|
||||
}
|
||||
for _, v := range invalidNames {
|
||||
_, errors := validateRedshiftClusterDbName(v, "name")
|
||||
|
Loading…
Reference in New Issue
Block a user