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

applying aws_lb_listener resource changes require adding additional stickiness optional parameters #14119

Closed
jnichols3 opened this issue Jul 9, 2020 · 3 comments · Fixed by #35671
Assignees
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/ec2 Issues and PRs that pertain to the ec2 service. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Milestone

Comments

@jnichols3
Copy link

jnichols3 commented Jul 9, 2020

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 other comments that do not add relevant new information or questions, 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 -v
Terraform v0.12.28
+ provider.aws v2.69.0

Affected Resource(s)

  • aws_lb_listener

Terraform Configuration Files

provider "aws" {
  version = "~> v2.69.0"
  region  = "us-east-1"
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "=v2.44.0"

  name = "tf-test"

  cidr            = "10.59.0.0/16"
  public_subnets  = ["10.59.0.0/20"]
  private_subnets = ["10.59.48.0/20","10.59.64.0/20"]

  azs = ["us-east-1a","us-east-1b"]
}

resource "aws_security_group" "allow_www" {
  name        = "alb-allow-www"
  vpc_id      = module.vpc.vpc_id

  ingress {
    description = "HTTP from the Internet"
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}
resource "aws_lb" "test" {
  name               = "test-alb"
  internal           = false
  load_balancer_type = "application"
  security_groups    = [aws_security_group.allow_www.id]
  subnets            = module.vpc.private_subnets
}

resource "aws_lb_target_group" "test-big" {
  name        = "test-big"
  port        = 80
  protocol    = "HTTP"
  target_type = "ip"
  vpc_id      = module.vpc.vpc_id

  health_check {
    protocol = "HTTP"
    port     = 80
    path     = "/healthcheck"
  }
}

resource "aws_lb_target_group_attachment" "test-big" {
  port              = 80
  target_id         = "10.1.1.1"
  target_group_arn  = aws_lb_target_group.test-big.arn
  availability_zone = "all"
}

resource "aws_lb_target_group" "test-small" {
  name        = "test-small"
  port        = 80
  protocol    = "HTTP"
  target_type = "ip"
  vpc_id      = module.vpc.vpc_id

  health_check {
    protocol = "HTTP"
    port     = 80
    path     = "/healthcheck"
  }
}

resource "aws_lb_target_group_attachment" "test-small" {
  port              = 80
  target_id         = "10.1.1.2"
  target_group_arn  = aws_lb_target_group.test-small.arn
  availability_zone = "all"
}

resource "aws_lb_listener" "test-http-listener" {
  load_balancer_arn = aws_lb.test.arn
  port              = "80"
  protocol          = "HTTP"

  default_action {
    type = "forward"
    forward {
      target_group {
        arn    = aws_lb_target_group.test-big.arn
        weight = 250
      }
      target_group {
        arn    = aws_lb_target_group.test-small.arn
        weight = 80
      }
    }
  }
}

Debug Output

https://gist.github.com/jnicholsthru/9c629a40aa22122e5b6b1b54bff1d803

Panic Output

Expected Behavior

When making a change to an aws_lb_listener resource such as a target weight, the change should apply successfully.

Actual Behavior

A ValidationError is encountered, requiring additional options parameters to be specified for stickiness.

	status code: 400, request id: f0f0cd1a-19bf-42f6-82a9-d2049ec015e4

  on alb.tf line 90, in resource "aws_lb_listener" "test-http-listener":
  90: resource "aws_lb_listener" "test-http-listener" {

Steps to Reproduce

  1. terraform apply
  2. update one of the target_group weights, port or other aws_lb_listener parameter
  3. terraform apply

The only way to proceed with applying changes is to add a stickness under the forward block.

resource "aws_lb_listener" "test-http-listener" {
  load_balancer_arn = aws_lb.test.arn
  port              = "80"
  protocol          = "HTTP"

  default_action {
    type = "forward"
    forward {
      target_group {
        arn    = aws_lb_target_group.test-big.arn
        weight = 250
      }
      target_group {
        arn    = aws_lb_target_group.test-small.arn
        weight = 80
      }
      stickiness {
        duration = 1
        enabled  = false
      }
    }
  }
}

Important Factoids

The documentation for the resource: https://www.terraform.io/docs/providers/aws/r/lb_listener.html#stickiness
indicates that stickiness parameter in forward blocks is optional, but it appears to be setting invalid defaults when a stickiness block is not defined.

References

@ghost ghost added service/ec2 Issues and PRs that pertain to the ec2 service. service/elbv2 Issues and PRs that pertain to the elbv2 service. labels Jul 9, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 9, 2020
@breathingdust breathingdust added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 10, 2020
@zhelding zhelding assigned zhelding and unassigned zhelding Sep 13, 2021
@gdavison gdavison self-assigned this Jan 15, 2024
@gdavison
Copy link
Contributor

Related to #22526

@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jan 15, 2024
@github-actions github-actions bot added this to the v5.36.0 milestone Feb 7, 2024
@github-actions github-actions bot removed the bug Addresses a defect in current functionality. label Feb 8, 2024
Copy link

github-actions bot commented Feb 8, 2024

This functionality has been released in v5.36.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Feb 10, 2024
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2024
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. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/ec2 Issues and PRs that pertain to the ec2 service. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
5 participants