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/lb_target_group: fix compatibility with Network Load Balancers #2251

Merged
merged 4 commits into from
Nov 13, 2017

Conversation

catsby
Copy link
Contributor

@catsby catsby commented Nov 10, 2017

Supersedes #1884

  • adds a simple error check on setting health_check
  • add documentation about stickiness and Network LBs
  • Implement test

Fixes #1912


Test results

TF_ACC=1 go test ./aws -v -run=TestAccAWSLBTargetGroup_ -timeout 120m
=== RUN   TestAccAWSLBTargetGroup_basic
--- PASS: TestAccAWSLBTargetGroup_basic (26.49s)
=== RUN   TestAccAWSLBTargetGroup_networkLB_TargetGroup
--- PASS: TestAccAWSLBTargetGroup_networkLB_TargetGroup (26.17s)
=== RUN   TestAccAWSLBTargetGroup_namePrefix
--- PASS: TestAccAWSLBTargetGroup_namePrefix (25.68s)
=== RUN   TestAccAWSLBTargetGroup_generatedName
--- PASS: TestAccAWSLBTargetGroup_generatedName (24.66s)
=== RUN   TestAccAWSLBTargetGroup_changeNameForceNew
--- PASS: TestAccAWSLBTargetGroup_changeNameForceNew (44.56s)
=== RUN   TestAccAWSLBTargetGroup_changeProtocolForceNew
--- PASS: TestAccAWSLBTargetGroup_changeProtocolForceNew (46.48s)
=== RUN   TestAccAWSLBTargetGroup_changePortForceNew
--- PASS: TestAccAWSLBTargetGroup_changePortForceNew (43.55s)
=== RUN   TestAccAWSLBTargetGroup_changeVpcForceNew
--- PASS: TestAccAWSLBTargetGroup_changeVpcForceNew (40.32s)
=== RUN   TestAccAWSLBTargetGroup_tags
--- PASS: TestAccAWSLBTargetGroup_tags (40.29s)
=== RUN   TestAccAWSLBTargetGroup_updateHealthCheck
--- PASS: TestAccAWSLBTargetGroup_updateHealthCheck (42.46s)
=== RUN   TestAccAWSLBTargetGroup_updateSticknessEnabled
--- PASS: TestAccAWSLBTargetGroup_updateSticknessEnabled (57.63s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       418.337s

@catsby
Copy link
Contributor Author

catsby commented Nov 10, 2017

Hey @DaveBlooman if you have a minute please take a look here! 5b1b3fc is my additions to your original PR #1884

@catsby catsby mentioned this pull request Nov 10, 2017
@dblooman
Copy link
Contributor

@catsby I squashed my commits, so your commit is based on my initial commit, not my latest 0d9e713

@catsby
Copy link
Contributor Author

catsby commented Nov 10, 2017

@DaveBlooman ah thanks for pointing that out, I rebased and should be fixed now

@catsby
Copy link
Contributor Author

catsby commented Nov 11, 2017

We had some failing tests due to a typo, I patched that in c93f98a

@dblooman
Copy link
Contributor

@catsby LGTM

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Just two, rather lower prio comments.
Otherwise LGTM - thanks @DaveBlooman for the original PR.

params.Matcher = &elbv2.Matcher{
HttpCode: aws.String(healthCheck["matcher"].(string)),

if *params.Protocol != "TCP" {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be a bit more future-proof and cleaner if we checked each argument separately regardless of the protocol. That said it would probably require removing all defaults from these fields and making them computed, which introduces some other potential troubles during updates.

The downside of the current solution is that we're silently ignoring certain arguments without ever telling the user which may backfire if AWS decides to support any of these arguments in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed this isn't ideal, but I'm going to go forward as is. Part of me wonders if the real solution would have been to keep ALB and LB as separate resources entirely 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed on that point, It is a shame to make a breaking change, but as more specific features are added to each type, they will diverge more. Let's see what aws do at re: invent

if *targetGroup.Protocol != "TCP" {
healthCheck["path"] = *targetGroup.HealthCheckPath
healthCheck["matcher"] = *targetGroup.Matcher.HttpCode
}
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, but we could do something like this

if targetGroup.HealthCheckPath != nil {
    healthCheck["path"] = *targetGroup.HealthCheckPath
}
if targetGroup.Matcher.HttpCode != nil {
    healthCheck["matcher"] = *targetGroup.Matcher.HttpCode
}

I know that HTTP health check arguments will never be supported for TCP LB, but it feels a little bit cleaner 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 applied in 3310363

@catsby
Copy link
Contributor Author

catsby commented Nov 13, 2017

I applied feedback suggested and re-ran tests:

=== RUN   TestAccAWSLBTargetGroup_basic
--- PASS: TestAccAWSLBTargetGroup_basic (23.06s)
=== RUN   TestAccAWSLBTargetGroup_networkLB_TargetGroup
--- PASS: TestAccAWSLBTargetGroup_networkLB_TargetGroup (21.93s)
=== RUN   TestAccAWSLBTargetGroup_namePrefix
--- PASS: TestAccAWSLBTargetGroup_namePrefix (22.22s)
=== RUN   TestAccAWSLBTargetGroup_generatedName
--- PASS: TestAccAWSLBTargetGroup_generatedName (21.84s)
=== RUN   TestAccAWSLBTargetGroup_changeNameForceNew
--- PASS: TestAccAWSLBTargetGroup_changeNameForceNew (37.20s)
=== RUN   TestAccAWSLBTargetGroup_changeProtocolForceNew
--- PASS: TestAccAWSLBTargetGroup_changeProtocolForceNew (41.59s)
=== RUN   TestAccAWSLBTargetGroup_changePortForceNew
--- PASS: TestAccAWSLBTargetGroup_changePortForceNew (37.43s)
=== RUN   TestAccAWSLBTargetGroup_changeVpcForceNew
--- PASS: TestAccAWSLBTargetGroup_changeVpcForceNew (33.66s)
=== RUN   TestAccAWSLBTargetGroup_tags
--- PASS: TestAccAWSLBTargetGroup_tags (38.11s)
=== RUN   TestAccAWSLBTargetGroup_updateHealthCheck
--- PASS: TestAccAWSLBTargetGroup_updateHealthCheck (36.82s)
=== RUN   TestAccAWSLBTargetGroup_updateSticknessEnabled
--- PASS: TestAccAWSLBTargetGroup_updateSticknessEnabled (51.31s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       365.186s

Going to merge this now

@dcloud9
Copy link

dcloud9 commented Nov 16, 2017

@catsby - thanks for merging to master, NLB target group TCP proto.
As 1.3.0 is yet to be released, we can make build master branch and move the bin/terraform-provider-aws to .terraform_plugins/ as interim, happy days.

@catsby
Copy link
Contributor Author

catsby commented Nov 16, 2017

@dcloud9 awesome! I believe v1.3.0 should come out soon

@AnishAnil
Copy link

This is a critical blocker for our atomation. I'm unable to create a Network LB.
What is the ETA to have this fixed

@radeksimko
Copy link
Member

@AnishAnil this was shipped yesterday in 1.3.0

@wjglerum
Copy link

wjglerum commented Nov 17, 2017

Today I got this error message on a deploy:
ValidationError: Health check matcher HTTP code cannot be empty

After some searching I found this in the changelog:
resource/aws_lb_target_group: We no longer provide defaults for health_check's path nor matcher in order to support network load balancers where these arguments aren't valid. Creating new ALB will therefore require you to specify these two arguments. Existing deployments are unaffected. (#2251)

However the documentation still says it is optional and provides a default:
matcher (Optional) The HTTP codes to use when checking for a successful response from a target. Defaults to 200. You can specify multiple values (for example, "200,202") or a range of values (for example, "200-299").

@wjglerum
Copy link

The same goes for the health_check path which is also not updated in the documentation

@radeksimko
Copy link
Member

radeksimko commented Nov 17, 2017

@wjglerum that's tracked under #2327 and #2343 - feel free to subscribe to that issue using the button in the right sidebar.

Sorry for the troubles.

@wjglerum
Copy link

Thanks, didn't see that issue.

@catsby
Copy link
Contributor Author

catsby commented Nov 20, 2017

#2380 is a follow-up PR to this

blaines added a commit to blaines/terraform-provider-aws that referenced this pull request Nov 22, 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lb_target_group not compatible with aws_lb of type network
6 participants