Skip to content

Commit

Permalink
resource/aws_globalaccelerator_accelerator: Correct name validation l…
Browse files Browse the repository at this point in the history
…ength (#17985)

Output from acceptance testing in AWS Commercial:

```
--- FAIL: TestAccAwsGlobalAcceleratorAccelerator_attributes (361.78s) # #18121
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_basic (78.46s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_disappears (73.64s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_tags (107.66s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_update (166.17s)

--- PASS: TestAccAwsGlobalAcceleratorListener_basic (136.40s)
--- PASS: TestAccAwsGlobalAcceleratorListener_disappears (134.18s)
--- PASS: TestAccAwsGlobalAcceleratorListener_update (178.99s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- SKIP: TestAccAwsGlobalAcceleratorAccelerator_attributes (30.06s)
--- SKIP: TestAccAwsGlobalAcceleratorAccelerator_basic (36.40s)
--- SKIP: TestAccAwsGlobalAcceleratorAccelerator_tags (28.51s)
--- SKIP: TestAccAwsGlobalAcceleratorAccelerator_update (27.43s)
--- SKIP: TestAccAwsGlobalAcceleratorAccelerator_disappears (28.93s)

--- SKIP: TestAccAwsGlobalAcceleratorListener_basic (28.74s)
--- SKIP: TestAccAwsGlobalAcceleratorListener_disappears (31.23s)
--- SKIP: TestAccAwsGlobalAcceleratorListener_update (30.72s)
```
  • Loading branch information
ewbankkit authored Mar 16, 2021
1 parent 2f858b3 commit 9ffa207
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
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
Expand Up @@ -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"),
Expand Down
28 changes: 11 additions & 17 deletions aws/resource_aws_globalaccelerator_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
},
},
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ffa207

Please sign in to comment.