diff --git a/aws/resource_aws_db_parameter_group_test.go b/aws/resource_aws_db_parameter_group_test.go index 1d330bfc7cc..7348569d4ff 100644 --- a/aws/resource_aws_db_parameter_group_test.go +++ b/aws/resource_aws_db_parameter_group_test.go @@ -413,6 +413,10 @@ func TestResourceAWSDBParameterGroupName_validation(t *testing.T) { Value: "testing--123", ErrCount: 1, }, + { + Value: "testing__123", + ErrCount: 1, + }, { Value: "testing123-", ErrCount: 1, diff --git a/aws/validators.go b/aws/validators.go index 7ea9873eedb..b832737036a 100644 --- a/aws/validators.go +++ b/aws/validators.go @@ -100,9 +100,9 @@ func validateTagFilters(v interface{}, k string) (ws []string, errors []error) { func validateDbParamGroupName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexp.MustCompile(`^[0-9a-z-]+$`).MatchString(value) { + if !regexp.MustCompile(`^[0-9a-z-_]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( - "only lowercase alphanumeric characters and hyphens allowed in %q", k)) + "only lowercase alphanumeric characters, underscores and hyphens allowed in %q", k)) } if !regexp.MustCompile(`^[a-z]`).MatchString(value) { errors = append(errors, fmt.Errorf( @@ -112,6 +112,10 @@ func validateDbParamGroupName(v interface{}, k string) (ws []string, errors []er errors = append(errors, fmt.Errorf( "%q cannot contain two consecutive hyphens", k)) } + if regexp.MustCompile(`__`).MatchString(value) { + errors = append(errors, fmt.Errorf( + "%q cannot contain two consecutive underscores", k)) + } if regexp.MustCompile(`-$`).MatchString(value) { errors = append(errors, fmt.Errorf( "%q cannot end with a hyphen", k))