-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
r/aws_globalaccelerator_listener: Add aws_globalaccelerator_listener resource #7003
Conversation
This is ready for rebase with master 👍 |
57148b1
to
be796c8
Compare
@bflad : Rebased onto master and re-run the acceptance tests. Sorry for lack of response recently - been a bit snowed under. |
There was a problem hiding this 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{ |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
Computed: true, | |
Default: globalaccelerator.ClientAffinityNone, |
}, false), | ||
}, | ||
"port_range": { | ||
Type: schema.TypeList, |
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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.
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. 🚀
|
Output from acceptance testing: ``` --- PASS: TestAccAwsGlobalAcceleratorListener_basic (71.30s) --- PASS: TestAccAwsGlobalAcceleratorListener_update (81.22s) ```
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. |
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! |
Partly addresses #6739
Changes proposed in this pull request:
aws_globalaccelerator_listener
Output from acceptance testing: