Skip to content

Commit

Permalink
fix: Fix EKS cluster name regex
Browse files Browse the repository at this point in the history
  • Loading branch information
acwwat committed Feb 20, 2024
1 parent c7623b0 commit 8822a47
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/35874.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_eks_cluster: Fix cluster name regex that incorrectly disallowed single-character names
```
2 changes: 1 addition & 1 deletion internal/service/eks/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func validClusterName(v interface{}, k string) (ws []string, errors []error) {
}

// https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateCluster.html#API_CreateCluster_RequestSyntax
pattern := `^[0-9A-Za-z][0-9A-Za-z_-]+$`
pattern := `^[0-9A-Za-z][0-9A-Za-z_-]*$`
if !regexache.MustCompile(pattern).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q doesn't comply with restrictions (%q): %q",
Expand Down
4 changes: 4 additions & 0 deletions internal/service/eks/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func TestValidClusterName(t *testing.T) {
Value: "my-valid-eks-cluster_1_dev",
ErrCount: 0,
},
{
Value: "a",
ErrCount: 0,
},
{
Value: `_invalid`,
ErrCount: 1,
Expand Down

0 comments on commit 8822a47

Please sign in to comment.