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

resource/aws_alb_target_group: Add support for target_type #1589

Merged
merged 2 commits into from
Oct 26, 2017

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Sep 5, 2017

Fixes: #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

Copy link
Contributor

@Ninir Ninir left a 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)

Optional: true,
Default: "instance",
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"ip", "instance"}, true),
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@Ninir Ninir Sep 8, 2017

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).
Copy link
Contributor

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,
Copy link
Contributor

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

@stack72
Copy link
Contributor Author

stack72 commented Sep 8, 2017

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.

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Sep 11, 2017
@stack72
Copy link
Contributor Author

stack72 commented Sep 13, 2017

Hi @Ninir

I made the docs changes and just removed the validation check - I believe this is ready to go now

P.

@Ninir
Copy link
Contributor

Ninir commented Sep 15, 2017

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 Ninir added the waiting-response Maintainers are waiting on response from community or contributor. label Sep 15, 2017
@stack72
Copy link
Contributor Author

stack72 commented Sep 23, 2017

@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

@f3lang
Copy link
Contributor

f3lang commented Sep 28, 2017

@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.

@stack72 stack72 force-pushed the f-aws-alb-target-group-type branch from 2c07d41 to 893d6b5 Compare October 4, 2017 12:49
@stack72
Copy link
Contributor Author

stack72 commented Oct 4, 2017

Hi @f3lang

Thanks for the feedback here - you are indeed correct, I just updated the PR to include availability_zone in the alb_target_group_attachment

terraform-provider-aws [f-aws-alb-target-group-type●] % acctests aws TestAccAWSALBTargetGroupAttachment_
=== RUN   TestAccAWSALBTargetGroupAttachment_basic
--- PASS: TestAccAWSALBTargetGroupAttachment_basic (143.64s)
=== RUN   TestAccAWSALBTargetGroupAttachment_withoutPort
--- PASS: TestAccAWSALBTargetGroupAttachment_withoutPort (150.73s)
=== RUN   TestAccAWSALBTargetGroupAttachment_ipAddress
--- PASS: TestAccAWSALBTargetGroupAttachment_ipAddress (150.28s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	444.678s

Thanks for the nudge on this :)

P.

@stack72
Copy link
Contributor Author

stack72 commented Oct 4, 2017

@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
```
@stack72 stack72 force-pushed the f-aws-alb-target-group-type branch from 893d6b5 to 7e2a397 Compare October 5, 2017 11:45
@Ninir
Copy link
Contributor

Ninir commented Oct 11, 2017

@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!

@alex1x
Copy link
Contributor

alex1x commented Oct 26, 2017

Would be great to have this finalized, this is an important missing feature.

Copy link
Contributor

@Ninir Ninir left a 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!

@Ninir Ninir merged commit 8d66014 into hashicorp:master Oct 26, 2017
@ghost
Copy link

ghost commented Apr 10, 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 Apr 10, 2020
@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
enhancement Requests to existing resources that expand the functionality or scope.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: aws_alb_target_group_attachment - Support for new "IP" target type
5 participants