-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
resource/aws_alb_target_group: Add support for target_type
#1589
Conversation
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.
Hi @stack72 ,
This LGTM! just left a few comments to address :)
Tests are passing though :)
$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSALBTargetGroupAttachment_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSALBTargetGroupAttachment_basic -timeout 120m
=== RUN TestAccAWSALBTargetGroup_basic
--- PASS: TestAccAWSALBTargetGroup_basic (57.32s)
=== RUN TestAccAWSALBTargetGroup_namePrefix
--- PASS: TestAccAWSALBTargetGroup_namePrefix (61.87s)
=== RUN TestAccAWSALBTargetGroup_generatedName
--- PASS: TestAccAWSALBTargetGroup_generatedName (53.07s)
=== RUN TestAccAWSALBTargetGroup_changeNameForceNew
--- PASS: TestAccAWSALBTargetGroup_changeNameForceNew (90.71s)
=== RUN TestAccAWSALBTargetGroup_changeProtocolForceNew
--- PASS: TestAccAWSALBTargetGroup_changeProtocolForceNew (93.98s)
=== RUN TestAccAWSALBTargetGroup_changePortForceNew
--- PASS: TestAccAWSALBTargetGroup_changePortForceNew (89.92s)
=== RUN TestAccAWSALBTargetGroup_changeVpcForceNew
--- PASS: TestAccAWSALBTargetGroup_changeVpcForceNew (84.06s)
=== RUN TestAccAWSALBTargetGroup_tags
--- PASS: TestAccAWSALBTargetGroup_tags (88.30s)
=== RUN TestAccAWSALBTargetGroup_updateHealthCheck
--- PASS: TestAccAWSALBTargetGroup_updateHealthCheck (87.04s)
=== RUN TestAccAWSALBTargetGroup_updateSticknessEnabled
--- PASS: TestAccAWSALBTargetGroup_updateSticknessEnabled (114.76s)
aws/resource_aws_alb_target_group.go
Outdated
Optional: true, | ||
Default: "instance", | ||
ForceNew: true, | ||
ValidateFunc: validation.StringInSlice([]string{"ip", "instance"}, 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.
Could you prefer the use of constants (TargetTypeEnumInstance & TargetTypeEnumIp) here?
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.
I don't see what extra that would give us? It's for validation of what the user inputs - i'm interested in seeing what you think
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.
By using SDK constants everywhere, you rely on the same exact value everywhere.
Relying on a user-typed string can brings issues if any typo is made. Thus, that's why we try to stick to them as much as possible, whenever they exist.
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.
I will update the PR to remove the validation - I don't see any reason why we need to use constants when the values are ip
or instance
- if they were longer strings then I would understand
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.
Paul,
Perhaps I was misleading in my comment, but the validation was fine.
Was just wondering if we could do that:
ValidateFunc: validation.StringInSlice([]string{elbv2.TargetTypeEnumInstance, elbv2.TargetTypeEnumIp}, true),
Sorry if it was not clear at all 😅
@@ -39,6 +39,12 @@ The following arguments are supported: | |||
* `deregistration_delay` - (Optional) The amount time for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused. The range is 0-3600 seconds. The default value is 300 seconds. | |||
* `stickiness` - (Optional) A Stickiness block. Stickiness blocks are documented below. | |||
* `health_check` - (Optional) A Health Check block. Health Check blocks are documented below. | |||
* `target_type` - (Optional) The type of target that you must specify when registering targets with this target group. | |||
The possible values are i`nstance` (targets are specified by instance ID) or `ip` (targets are specified by IP address). |
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.
Typo in instance
* `target_type` - (Optional) The type of target that you must specify when registering targets with this target group. | ||
The possible values are i`nstance` (targets are specified by instance ID) or `ip` (targets are specified by IP address). | ||
The default is `instance`. Note that you can't specify targets for a target group using both instance IDs and IP addresses. | ||
If the target type is `ip` , specify IP addresses from the subnets of the virtual private cloud (VPC) for the target group, |
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.
Additional space before the comma
Thanks for the review @Ninir - made the docs changes - I don't agree with the constants change but i'm willing to listen to why P. |
04c6f81
to
2c07d41
Compare
Hi @Ninir I made the docs changes and just removed the validation check - I believe this is ready to go now P. |
This looks very good to me! Just a small question: shouldn't we add a validation for that? do you think adding it will restrict us as soon as there is a new potential target? Will make the last review & run tests as soon as I get your answer on that :) Thanks a lot! 👍 |
@Ninir I think validation of that type will restrict us going forward - I had a huge conversation with @tombuildsstuff about validation the other day and the types we do feel wrong. Think of how long it has been since an AWS provider release IF a new target was added, then it stops people using the provider |
@stack72 At first, great change :) I just did a test in my staging environment and stumbled upon an issue, that currently exists, when you try to attach ip targets. When you attach an instance target, aws knows the availability zone. But when you attach an ip target to a target group with the target_type "ip", you need to tell AWS the Availability Zone of the target. If the target is not within a VPC, but on-premise, you need to set the Availability Zone of the target to "all". The aws_alb_target_group_attachment doesn't have the availability_zone option right now, so the attachment process fails. |
2c07d41
to
893d6b5
Compare
Hi @f3lang Thanks for the feedback here - you are indeed correct, I just updated the PR to include
Thanks for the nudge on this :) P. |
@Ninir I don't believe we should add validation here so I believe this can be finalized Paul |
Fixes: hashicorp#1588 ``` % make testacc TEST=./aws TESTARGS='-run=TestAccAWSALBTargetGroup_' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -run=TestAccAWSALBTargetGroup_ -timeout 120m === RUN TestAccAWSALBTargetGroup_basic --- PASS: TestAccAWSALBTargetGroup_basic (73.55s) === RUN TestAccAWSALBTargetGroup_namePrefix --- PASS: TestAccAWSALBTargetGroup_namePrefix (72.26s) === RUN TestAccAWSALBTargetGroup_generatedName --- PASS: TestAccAWSALBTargetGroup_generatedName (74.94s) === RUN TestAccAWSALBTargetGroup_changeNameForceNew --- PASS: TestAccAWSALBTargetGroup_changeNameForceNew (129.78s) === RUN TestAccAWSALBTargetGroup_changeProtocolForceNew --- PASS: TestAccAWSALBTargetGroup_changeProtocolForceNew (151.66s) === RUN TestAccAWSALBTargetGroup_changePortForceNew --- PASS: TestAccAWSALBTargetGroup_changePortForceNew (129.73s) === RUN TestAccAWSALBTargetGroup_changeVpcForceNew --- PASS: TestAccAWSALBTargetGroup_changeVpcForceNew (112.48s) === RUN TestAccAWSALBTargetGroup_tags --- PASS: TestAccAWSALBTargetGroup_tags (124.72s) === RUN TestAccAWSALBTargetGroup_updateHealthCheck --- PASS: TestAccAWSALBTargetGroup_updateHealthCheck (122.61s) === RUN TestAccAWSALBTargetGroup_updateSticknessEnabled --- PASS: TestAccAWSALBTargetGroup_updateSticknessEnabled (170.23s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 1161.982s ```
893d6b5
to
7e2a397
Compare
@stack72 hey Paul, Could you fix the Go issue (aws/resource_aws_alb_target_group_test.go:41:13: undefined: albTargetGroupSuffixFromARN)? Can't test it right now :/ Will run tests & merge as soon as it's all ok. Thanks! |
Would be great to have this finalized, this is an important missing feature. |
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.
LGTM! 👍
@stack72 Took the liberty to update and fix the issue regarding the wrong method name usage.
$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSALBTargetGroup_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSALBTargetGroup_ -timeout 120m
=== RUN TestAccAWSALBTargetGroup_basic
--- PASS: TestAccAWSALBTargetGroup_basic (19.96s)
=== RUN TestAccAWSALBTargetGroup_namePrefix
--- PASS: TestAccAWSALBTargetGroup_namePrefix (18.92s)
=== RUN TestAccAWSALBTargetGroup_generatedName
--- PASS: TestAccAWSALBTargetGroup_generatedName (18.86s)
=== RUN TestAccAWSALBTargetGroup_changeNameForceNew
--- PASS: TestAccAWSALBTargetGroup_changeNameForceNew (33.44s)
=== RUN TestAccAWSALBTargetGroup_changeProtocolForceNew
--- PASS: TestAccAWSALBTargetGroup_changeProtocolForceNew (36.35s)
=== RUN TestAccAWSALBTargetGroup_changePortForceNew
--- PASS: TestAccAWSALBTargetGroup_changePortForceNew (33.36s)
=== RUN TestAccAWSALBTargetGroup_changeVpcForceNew
--- PASS: TestAccAWSALBTargetGroup_changeVpcForceNew (30.39s)
=== RUN TestAccAWSALBTargetGroup_tags
--- PASS: TestAccAWSALBTargetGroup_tags (31.86s)
=== RUN TestAccAWSALBTargetGroup_updateHealthCheck
--- PASS: TestAccAWSALBTargetGroup_updateHealthCheck (32.79s)
=== RUN TestAccAWSALBTargetGroup_updateSticknessEnabled
--- PASS: TestAccAWSALBTargetGroup_updateSticknessEnabled (45.29s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 301.249s
Thanks for the work!
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! |
Fixes: #1588