From c5c2d27e2559206351983478898f5d700beb0d41 Mon Sep 17 00:00:00 2001 From: Brad Larson Date: Tue, 24 Jan 2017 15:47:45 +0000 Subject: [PATCH] Fix: Incorrect AWS Lambda Qualifier Regexp 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. --- builtin/providers/aws/validators.go | 2 +- builtin/providers/aws/validators_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/validators.go b/builtin/providers/aws/validators.go index 499a9ee2b..adaaecb57 100644 --- a/builtin/providers/aws/validators.go +++ b/builtin/providers/aws/validators.go @@ -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", diff --git a/builtin/providers/aws/validators_test.go b/builtin/providers/aws/validators_test.go index e16391c15..7cfb5b92a 100644 --- a/builtin/providers/aws/validators_test.go +++ b/builtin/providers/aws/validators_test.go @@ -111,6 +111,8 @@ func TestValidateLambdaQualifier(t *testing.T) { "prod", "PROD", "MyTestEnv", + "contains-dashes", + "contains_underscores", "$LATEST", } for _, v := range validNames {