Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_globalaccelerator_accelerator: Correct name validation length #17985

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/17985.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_globalaccelerator_accelerator: Correct length for `name` attribute validation
```
2 changes: 1 addition & 1 deletion aws/resource_aws_globalaccelerator_accelerator.go
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ func resourceAwsGlobalAcceleratorAccelerator() *schema.Resource {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.All(
validation.StringLenBetween(1, 32),
validation.StringLenBetween(1, 255),
validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z-]+$`), "only alphanumeric characters and hyphens are allowed"),
validation.StringDoesNotMatch(regexp.MustCompile(`^-`), "cannot start with a hyphen"),
validation.StringDoesNotMatch(regexp.MustCompile(`-$`), "cannot end with a hyphen"),
28 changes: 11 additions & 17 deletions aws/resource_aws_globalaccelerator_listener.go
Original file line number Diff line number Diff line change
@@ -41,21 +41,15 @@ func resourceAwsGlobalAcceleratorListener() *schema.Resource {
ForceNew: true,
},
"client_affinity": {
Type: schema.TypeString,
Optional: true,
Default: globalaccelerator.ClientAffinityNone,
ValidateFunc: validation.StringInSlice([]string{
globalaccelerator.ClientAffinityNone,
globalaccelerator.ClientAffinitySourceIp,
}, false),
Type: schema.TypeString,
Optional: true,
Default: globalaccelerator.ClientAffinityNone,
ValidateFunc: validation.StringInSlice(globalaccelerator.ClientAffinity_Values(), false),
},
"protocol": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
globalaccelerator.ProtocolTcp,
globalaccelerator.ProtocolUdp,
}, false),
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(globalaccelerator.Protocol_Values(), false),
},
"port_range": {
Type: schema.TypeSet,
@@ -67,12 +61,12 @@ func resourceAwsGlobalAcceleratorListener() *schema.Resource {
"from_port": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 65535),
ValidateFunc: validation.IsPortNumber,
},
"to_port": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 65535),
ValidateFunc: validation.IsPortNumber,
},
},
},
@@ -97,7 +91,7 @@ func resourceAwsGlobalAcceleratorListenerCreate(d *schema.ResourceData, meta int

resp, err := conn.CreateListener(opts)
if err != nil {
return fmt.Errorf("Error creating Global Accelerator listener: %s", err)
return fmt.Errorf("error creating Global Accelerator listener: %w", err)
}

d.SetId(aws.StringValue(resp.Listener.ListenerArn))
@@ -135,7 +129,7 @@ func resourceAwsGlobalAcceleratorListenerRead(d *schema.ResourceData, meta inter
d.Set("client_affinity", listener.ClientAffinity)
d.Set("protocol", listener.Protocol)
if err := d.Set("port_range", resourceAwsGlobalAcceleratorListenerFlattenPortRanges(listener.PortRanges)); err != nil {
return fmt.Errorf("error setting port_range: %s", err)
return fmt.Errorf("error setting port_range: %w", err)
}

return nil