Skip to content

Commit

Permalink
Merge pull request hashicorp#1460 from kirillshevch/bugfix/allow-unde…
Browse files Browse the repository at this point in the history
…rscore-rds

r/db_parameter_group: Allow underscores in names
  • Loading branch information
Ninir authored Aug 21, 2017
2 parents 5f69c23 + 5174361 commit 90fe327
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions aws/resource_aws_db_parameter_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ func TestResourceAWSDBParameterGroupName_validation(t *testing.T) {
Value: "testing--123",
ErrCount: 1,
},
{
Value: "testing__123",
ErrCount: 1,
},
{
Value: "testing123-",
ErrCount: 1,
Expand Down
8 changes: 6 additions & 2 deletions aws/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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))
Expand Down

0 comments on commit 90fe327

Please sign in to comment.