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_listener: Add aws_globalaccelerator_listener resource #7003

Merged
merged 1 commit into from
Mar 15, 2019

Conversation

gazoakley
Copy link
Contributor

@gazoakley gazoakley commented Dec 29, 2018

Partly addresses #6739

Changes proposed in this pull request:

  • New Resource: aws_globalaccelerator_listener

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAwsGlobalAcceleratorListener'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsGlobalAcceleratorListener -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsGlobalAcceleratorListener_basic
=== PAUSE TestAccAwsGlobalAcceleratorListener_basic
=== RUN   TestAccAwsGlobalAcceleratorListener_update
=== PAUSE TestAccAwsGlobalAcceleratorListener_update
=== CONT  TestAccAwsGlobalAcceleratorListener_basic
=== CONT  TestAccAwsGlobalAcceleratorListener_update
--- PASS: TestAccAwsGlobalAcceleratorListener_basic (142.33s)
--- PASS: TestAccAwsGlobalAcceleratorListener_update (236.96s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	237.006s

@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. dependencies Used to indicate dependency changes. documentation Introduces or discusses updates to documentation. labels Dec 29, 2018
@gazoakley gazoakley changed the title r/aws_globalaccelerator_listener: Add aws_globalaccelerator_listener resource [WIP] r/aws_globalaccelerator_listener: Add aws_globalaccelerator_listener resource Dec 29, 2018
@gazoakley gazoakley changed the title [WIP] r/aws_globalaccelerator_listener: Add aws_globalaccelerator_listener resource r/aws_globalaccelerator_listener: Add aws_globalaccelerator_listener resource Dec 30, 2018
@bflad bflad removed the dependencies Used to indicate dependency changes. label Jan 16, 2019
@bflad
Copy link
Contributor

bflad commented Jan 16, 2019

This is ready for rebase with master 👍

@bflad bflad added waiting-response Maintainers are waiting on response from community or contributor. new-resource Introduces a new resource. service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service. labels Jan 16, 2019
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/XXL Managed by automation to categorize the size of a PR. labels Jan 16, 2019
@gazoakley
Copy link
Contributor Author

@bflad : Rebased onto master and re-run the acceptance tests. Sorry for lack of response recently - been a bit snowed under.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jan 16, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @gazoakley 👋 Thanks for this contribution! See below for some minor feedback. Please let us know if you have any questions or do not have time to implement these items. Thanks!

State: schema.ImportStatePassthrough,
},

Timeouts: &schema.ResourceTimeout{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should likely remove these customizable timeouts since:

  • They do not seem to be determined by a scalable resource such as amount of data
  • They are currently undocumented 😉

"client_affinity": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should switch this to Default: globalaccelerator.ClientAffinityNone, to match the API default and so we can properly perform drift detection when unconfigured.

Suggested change
Computed: true,
Default: globalaccelerator.ClientAffinityNone,

}, false),
},
"port_range": {
Type: schema.TypeList,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the ordering matter for these? If not, we should use schema.TypeSet. It would be nice to verify this either which way with an acceptance test that has multiple port_range configurations.

MaxItems: 10,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"from_port": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add plan-time validation for this attribute and to_port below. 👍

ValidateFunc: validation.IntBetween(1, 65535),

d.Set("accelerator_arn", acceleratorArn)
d.Set("client_affinity", listener.ClientAffinity)
d.Set("protocol", listener.Protocol)
d.Set("port_range", resourceAwsGlobalAcceleratorListenerFlattenPortRanges(listener.PortRanges))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using d.Set() with aggregate types (TypeList, TypeSet, TypeMap), we should perform error checking to prevent issues where the code is not properly able to set the Terraform state. e.g.

Suggested change
d.Set("port_range", resourceAwsGlobalAcceleratorListenerFlattenPortRanges(listener.PortRanges))
if err := d.Set("port_range", resourceAwsGlobalAcceleratorListenerFlattenPortRanges(listener.PortRanges)); err != nil {
return fmt.Errorf("error setting routing_config: %s", err)
}

for i, portRange := range portRanges {
m := make(map[string]interface{})

m["from_port"] = *portRange.FromPort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent potential panics we should use the AWS Go SDK provided helpers with FromPort and ToPort:

		m["from_port"] = aws.Int64Value(portRange.FromPort)
		m["to_port"] = aws.Int64Value(portRange.ToPort)

out[i] = m
}

log.Printf("[DEBUG] Flatten port_range: %s", out)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Extraneous logging can be removed. 👍

}

if v, ok := d.GetOk("client_affinity"); ok {
opts.ClientAffinity = aws.String(v.(string))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are switching client_affinity to have a default, this can be moved up into the above struct. 👍

The following arguments are supported:

* `accelerator_arn` - (Required) The Amazon Resource Name (ARN) of your accelerator.
* `client_affinity` - (Optional) The value for the address type must be `IPV4`. Valid values are `NONE`, `SOURCE_IP`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copypasta? 🍝 😄 We likely want to borrow some verbiage from https://docs.aws.amazon.com/global-accelerator/latest/api/API_CreateListener.html and link out to it for more information.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 4, 2019
@bflad bflad added this to the v2.2.0 milestone Mar 15, 2019
@bflad
Copy link
Contributor

bflad commented Mar 15, 2019

Hi again @gazoakley 👋 Since its been awhile since we heard from you here, we went ahead and addressed the feedback in a followup commit (32d6e68) so this can be released. Thanks for your contribution. 🚀

--- PASS: TestAccAwsGlobalAcceleratorListener_basic (71.30s)
--- PASS: TestAccAwsGlobalAcceleratorListener_update (81.22s)

@bflad bflad merged commit be796c8 into hashicorp:master Mar 15, 2019
bflad added a commit that referenced this pull request Mar 15, 2019
Output from acceptance testing:

```
--- PASS: TestAccAwsGlobalAcceleratorListener_basic (71.30s)
--- PASS: TestAccAwsGlobalAcceleratorListener_update (81.22s)
```
bflad added a commit that referenced this pull request Mar 15, 2019
@bflad
Copy link
Contributor

bflad commented Mar 15, 2019

This has been released in version 2.2.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
@gazoakley gazoakley deleted the f-globalaccelerator-listener branch April 7, 2020 16:18
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants