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

Error: Network Load Balancers do not support Stickiness #9093

Closed
oonisim opened this issue Jun 22, 2019 · 12 comments · Fixed by #15295
Closed

Error: Network Load Balancers do not support Stickiness #9093

oonisim opened this issue Jun 22, 2019 · 12 comments · Fixed by #15295
Assignees
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Milestone

Comments

@oonisim
Copy link

oonisim commented Jun 22, 2019

aws_lb for NLB with no stickiness configuration causes "Error: Network Load Balancers do not support Stickiness".

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.2
+ provider.aws v2.16.0

Affected Resource(s)

  • aws_lb
  • aws_lb_listener
  • aws_lb_target_group

Terraform Configuration Files

resource "aws_lb" "this" {
  load_balancer_type = "network"
  name               = "hoge"
  internal           = false

  subnets            = var.subnet_ids
  enable_cross_zone_load_balancing = true
}

resource "aws_lb_listener" "this" {
  load_balancer_arn   = aws_lb.this.arn
  port                = 80
  protocol            = "TCP"

  default_action {
    target_group_arn  = aws_lb_target_group.this.arn
    type              = "forward"
  }
}

resource "aws_lb_target_group" "this" {
  name_prefix           = "${substr(aws_lb.this.name, 0, 6)}"
  target_type           = "instance"
  vpc_id                = var.vpc_id
  port                  = 80
  protocol              = "TCP"
  lifecycle {
    create_before_destroy = true
  }
}

As in Resource: aws_lb_target_group, stickiness is optional, hence forcing to place it is a bug.

Debug Output

Panic Output

Expected Behavior

No error.

Actual Behavior

Error.

Error: Network Load Balancers do not support Stickiness

  on ../../../modules/nlb/nlb.tf line 21, in resource "aws_lb_target_group" "this":
  21: resource "aws_lb_target_group" "this" {

Steps to Reproduce

  1. terraform apply

Important Factoids

References

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 22, 2019
@aeschright aeschright added the service/elbv2 Issues and PRs that pertain to the elbv2 service. label Jul 3, 2019
@darrenfurr
Copy link

I added this as a workaround to my target_group & it worked:

stickiness {
    enabled = false
    type = "lb_cookie"
}

@aeschright aeschright added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Dec 13, 2019
@mountainerd
Copy link

mountainerd commented Mar 26, 2020

I am trying to deploy an NLB and am unable to do so at this point. The empty array workaround did not work and the stickiness block with enabled set to false also didn't work. At this point, being able to deploy NLBs via Terraform is dead in the water for me.

@demisx
Copy link

demisx commented May 9, 2020

I got passed this error in v0.12.24 with @darrenfurr suggestion:

resource "aws_lb_target_group" "node_port_http" {
  name  = "node-port-nlb-tg-http"
  port  = 80
  protocol = "TCP"
  vpc_id = <vpc_id>

  stickiness {
    enabled = false
    type = "lb_cookie"
  }
}

@christophla
Copy link

christophla commented Jun 18, 2020

I'm pretty sure NLB's do support stickiness at this point. There's a checkbox in the console to enable it on a target group.

@shivshankarb
Copy link

shivshankarb commented Jul 3, 2020

Yes, I confirmed with AWS support that stickiness can be configured and works for all types of ELBs. And applied it manually however it will be good to get this applied via terraform code.

@ishworg
Copy link

ishworg commented Jul 16, 2020

@darrenfurr and @demisx were you folks expecting the target groups to have stickiness ticked when you applied this? Or, was it to say that the Terraform AWS provider can successfully apply without error (albeit at the expense of faking it)?

@jstangroome
Copy link

Something like this would probably be sufficient:
jstangroome@3e3f73e

For better pre-apply validation, it could be extended to only allow stickness.type of source_ip for when protocol is tcp.

stickiness.type - The type of sticky sessions. The possible values are lb_cookie for Application Load Balancers or source_ip for Network Load Balancers.

https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_TargetGroupAttribute.html

@darrenfurr
Copy link

@ishworg -

@darrenfurr and @demisx were you folks expecting the target groups to have stickiness ticked when you applied this? Or, was it to say that the Terraform AWS provider can successfully apply without error (albeit at the expense of faking it)?

It was to say that TF applied successfully, but I had to "fake it" using the stickiness workaround above.

@madpipeline
Copy link
Contributor

The stickiness workaround only works for protocol TCP. For UDP I keep getting a Error: Error modifying Target Group Attributes: InvalidConfigurationRequest: The provided target group attribute is not supported.

If I apply again with no change, I see the change it tries to make is:

~ stickiness {
    ~ cookie_duration = 0 -> 86400
      enabled         = false
    ~ type            = "source_ip" -> "lb_cookie"
}

But the documentation states that type - (Required) The type of sticky sessions. The only current possible value is lb_cookie.

However, the AWS documentation states that the only type value for stickiness is source_ip.

@madpipeline
Copy link
Contributor

It seems like there exists a PR for this: #13762

@madpipeline
Copy link
Contributor

It seems the previous PR is stale as the author is nor responding. I've created another PR to hopefully get this in: #15295

@ghost
Copy link

ghost commented Nov 8, 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 as resolved and limited conversation to collaborators Nov 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.