Skip to content

Commit

Permalink
Fix: Incorrect AWS Lambda Qualifier Regexp
Browse files Browse the repository at this point in the history
Type of change:
===============
- Bug fix

What changed? ... and Why:
==========================
The regexp is currently set to:
`pattern := `^[a-zA-Z0-9$_]+$`

The AWS docs state that qualifer names must conform to the following
regexp:
`Pattern: (|[a-zA-Z0-9$_-]+)`

As you can see, the current regexp in Terraform is missing the `-` at
the end.

This addresses that.

How has it been tested?
=======================
Added a few test cases to the existing spec for `AwsLambdaQualifier`
validation.
  • Loading branch information
Brad Larson committed Jan 24, 2017
1 parent 6d026b1 commit c5c2d27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/providers/aws/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func validateLambdaQualifier(v interface{}, k string) (ws []string, errors []err
"%q cannot be longer than 128 characters: %q", k, value))
}
// http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html
pattern := `^[a-zA-Z0-9$_]+$`
pattern := `^[a-zA-Z0-9$_-]+$`
if !regexp.MustCompile(pattern).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q doesn't comply with restrictions (%q): %q",
Expand Down
2 changes: 2 additions & 0 deletions builtin/providers/aws/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func TestValidateLambdaQualifier(t *testing.T) {
"prod",
"PROD",
"MyTestEnv",
"contains-dashes",
"contains_underscores",
"$LATEST",
}
for _, v := range validNames {
Expand Down

0 comments on commit c5c2d27

Please sign in to comment.