Skip to content

Commit

Permalink
provider/aws: AWS IAM, User and Role allow + in the name (#9991)
Browse files Browse the repository at this point in the history
Fixes #9985

```
% make testacc TEST=./builtin/providers/aws
% TESTARGS='-run=TestValidateIamUserName'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/11/09 12:12:42 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestValidateIamUserName
-timeout 120m
=== RUN   TestValidateIamUserName
--- PASS: TestValidateIamUserName (0.00s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws0.026s
```
  • Loading branch information
stack72 authored Nov 9, 2016
1 parent d66359b commit 643d42c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions builtin/providers/aws/resource_aws_iam_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ func resourceAwsIamGroupDelete(d *schema.ResourceData, meta interface{}) error {

func validateAwsIamGroupName(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-Za-z=,.@\-_+]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"only alphanumeric characters, hyphens, underscores, commas, periods, @ symbols and equals signs allowed in %q: %q",
"only alphanumeric characters, hyphens, underscores, commas, periods, @ symbols, plus and equals signs allowed in %q: %q",
k, value))
}
return
Expand Down
1 change: 1 addition & 0 deletions builtin/providers/aws/resource_aws_iam_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestValidateIamGroupName(t *testing.T) {
"test.group",
"test.123,group",
"testgroup@hashicorp",
"test+group@hashicorp.com",
}
for _, v := range validNames {
_, errors := validateAwsIamGroupName(v, "name")
Expand Down
4 changes: 2 additions & 2 deletions builtin/providers/aws/resource_aws_iam_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ func resourceAwsIamUserDelete(d *schema.ResourceData, meta interface{}) error {

func validateAwsIamUserName(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-Za-z=,.@\-_+]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"only alphanumeric characters, hyphens, underscores, commas, periods, @ symbols and equals signs allowed in %q: %q",
"only alphanumeric characters, hyphens, underscores, commas, periods, @ symbols, plus and equals signs allowed in %q: %q",
k, value))
}
return
Expand Down
1 change: 1 addition & 0 deletions builtin/providers/aws/resource_aws_iam_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestValidateIamUserName(t *testing.T) {
"test.user",
"test.123,user",
"testuser@hashicorp",
"test+user@hashicorp.com",
}
for _, v := range validNames {
_, errors := validateAwsIamUserName(v, "name")
Expand Down

0 comments on commit 643d42c

Please sign in to comment.