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

aws_lb_listener default action not storing group stickiness properties if there is only one target group in the forward action #20200

Closed
eric32490 opened this issue Jul 15, 2021 · 4 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/elbv2 Issues and PRs that pertain to the elbv2 service.
Milestone

Comments

@eric32490
Copy link

eric32490 commented Jul 15, 2021

provider version: 3.49

I am currently using codedeploy to manage ECS Blue/Green Canary deployments
As I need to have stickiness enabled on the target groups, it also requires that the default action on the listener enables the "group stickiness", even during the times where there is only one target_group to be forwarded to

here is the code I wrote

resource "aws_lb_listener" "lb-listener" {
  load_balancer_arn = aws_lb.loadbalancer.arn
  port = 1443
  protocol = "HTTPS"
  ssl_policy = "ELBSecurityPolicy-TLS-1-2-2017-01"

  certificate_arn = var.lb_certificate_arn

  default_action {
    type = "forward"
    forward {
      target_group {
        arn = aws_lb_target_group.lb-tg.arn
        weight=1
      }

      stickiness {
        duration = 900
        enabled = true
      }
    }


  }

  lifecycle {
    ignore_changes = [
      default_action[0].target_group_arn
    ]
  }
}

Despite of this definition, terraform is simplifing the target groups definition and the result does not include stickness properties

terraform state show 'module.application-deploy-stage["gamma"].aws_lb_listener.lb-listener2'
# module.application-deploy-stage["gamma"].aws_lb_listener.lb-listener2:
resource "aws_lb_listener" "lb-listener2" {
    arn               = "arn:aws:elasticloadbalancing:eu-central-1:xxyyzz227484:listener/app/tf-lb-20210329094210037300000001/f5136585c1d718d5/cf278981636f3c5b"
    certificate_arn   = "arn:aws:acm:eu-central-1:xxyyzz227484:certificate/1934eccd-b61a-4fb2-ac6b-15f3d486023c"
    id                = "arn:aws:elasticloadbalancing:eu-central-1:xxyyzz227484:listener/app/tf-lb-20210329094210037300000001/f5136585c1d718d5/cf278981636f3c5b"
    load_balancer_arn = "arn:aws:elasticloadbalancing:eu-central-1:xxyyzz227484:loadbalancer/app/tf-lb-20210329094210037300000001/f5136585c1d718d5"
    port              = 1443
    protocol          = "HTTPS"
    ssl_policy        = "ELBSecurityPolicy-TLS-1-2-2017-01"
    tags              = {}
    tags_all          = {}

    default_action {
        order            = 1
        target_group_arn = "arn:aws:elasticloadbalancing:eu-central-1:xxyyzz227484:targetgroup/tf-20210329094425030600000002/fdd78d3fb3fdcca2"
        type             = "forward"
    }
}

As an example, here is an example definition I would like to have (TargetGroupStickinessConfig set with one target group)

aws elbv2 describe-listeners --load-balancer-arn arn:aws:elasticloadbalancing:eu-central-1:xxyyzz227484:loadbalancer/app/tf-lb-20210715131729154400000001/e89f36189cb98518
{
    "Listeners": [
(..)            "DefaultActions": [
                {
                    "Type": "forward",
                    "TargetGroupArn": "arn:aws:elasticloadbalancing:eu-central-1:xxyyzz227484:targetgroup/tf-20210715132033934600000003/05a0898d2e0b4d80",
                    "Order": 1,
                    "ForwardConfig": {
                        "TargetGroups": [
                            {
                                "TargetGroupArn": "arn:aws:elasticloadbalancing:eu-central-1:xxyyzz227484:targetgroup/tf-20210715132033934600000003/05a0898d2e0b4d80",
                                "Weight": 1
                            }
                        ],
                        "TargetGroupStickinessConfig": {
                            "Enabled": true,
                            "DurationSeconds": 3600
                        }
                    }
                }
            ]
        }
    ]
}
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/elbv2 Issues and PRs that pertain to the elbv2 service. labels Jul 15, 2021
@breathingdust breathingdust added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 31, 2021
@clint-truss
Copy link

I'm seeing this same behavior without the stickiness setting. Essentially, each time I have a ForwardConfig defined with one TargetGroup, after a TF apply, I can run a TF plan, and the ForwardConfig definition is removed and the Terraform in AWS is claims the state is:

default_action {
        order            = 1
        target_group_arn = "<targetarn>"
        type             = "forward"
    }

I can run an apply, which puts back my forward config, and then the next plan will show the drift again.

@gdavison
Copy link
Contributor

Related to #22526

@gdavison gdavison self-assigned this Jan 15, 2024
@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/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
5 participants