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

[Bug]: aws_lb_listener is refreshing not quite correct #32983

Closed
FlexTickets opened this issue Aug 13, 2023 · 5 comments · Fixed by #35671
Closed

[Bug]: aws_lb_listener is refreshing not quite correct #32983

FlexTickets opened this issue Aug 13, 2023 · 5 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

@FlexTickets
Copy link

FlexTickets commented Aug 13, 2023

Terraform Core Version

1.5.5

AWS Provider Version

5.12.0

Affected Resource(s)

aws_lb_listener

Expected Behavior

I've created alb listener by code:

resource "aws_lb_listener" "alb" {
  count                     = length(local.config)

  load_balancer_arn         = aws_lb.alb.arn
  port                      = local.config[count.index].port
  protocol                  = local.config[count.index].protocol

  tags = {
    Name                    = "${terraform.workspace}-alb-${local.config[count.index].port}"
    Description             = "${local.config[count.index]._comment}"
  }

  default_action {
    type                    = local.config[count.index].default_action
    forward {
        target_group {
          arn               = aws_lb_target_group.alb[count.index].arn
          weight            = 1
        }
        dynamic "stickiness" {
        for_each = { for k, v in [ local.config[count.index].stickiness ] : k => v if v != "" }
        content {
          duration          = local.config[count.index].stickiness
          enabled           = true
        }
      }
    }
  }
}

That is there is configuration block "forward" with subblock "stickiness". It's confirming by aws cli:

aws elbv2 describe-listeners --listener-arns arn:aws:elasticloadbalancing:eu-central-1:<account_id>:listener/app/cloud3-lb/397c8400222f6274/c8d08c40ceaf4bc5
{
    "Listeners": [
        {
            "ListenerArn": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:listener/app/cloud3-lb/397c8400222f6274/c8d08c40ceaf4bc5",
            "LoadBalancerArn": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:loadbalancer/app/cloud3-lb/397c8400222f6274",
            "Port": 8080,
            "Protocol": "HTTP",
            "DefaultActions": [
                {
                    "Type": "forward",
                    "TargetGroupArn": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:targetgroup/cloud3-alb-tg-8080/fc885ff52dbf1936",
                    "Order": 1,
                    "ForwardConfig": {
                        "TargetGroups": [
                            {
                                "TargetGroupArn": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:targetgroup/cloud3-alb-tg-8080/fc885ff52dbf1936",
                                "Weight": 1
                            }
                        ],
                        "TargetGroupStickinessConfig": {
                            "Enabled": true,
                            "DurationSeconds": 86400
                        }
                    }
                }
            ]
        }
    ]
}

And AWS console:
aws_lb_listener

Actual Behavior

I've got in state file:

          "index_key": 1,
          "schema_version": 0,
          "attributes": {
            "alpn_policy": null,
            "arn": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:listener/app/cloud3-lb/397c8400222f6274/c8d08c40ceaf4bc5",
            "certificate_arn": null,
            "default_action": [
              {
                "authenticate_cognito": [],
                "authenticate_oidc": [],
                "fixed_response": [],
                "forward": [],
                "order": 1,
                "redirect": [],
                "target_group_arn": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:targetgroup/cloud3-alb-tg-8080/fc885ff52dbf1936",
                "type": "forward"
              }
            ],
            "id": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:listener/app/cloud3-lb/397c8400222f6274/c8d08c40ceaf4bc5",
            "load_balancer_arn": "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:loadbalancer/app/cloud3-lb/397c8400222f6274",
            "port": 8080,
            "protocol": "HTTP",
            "ssl_policy": "",
            "tags": {
              "Description": "am",
              "Name": "cloud3-alb-8080"
            },
            "tags_all": {
              "Description": "am",
              "Name": "cloud3-alb-8080"
            },
            "timeouts": null
          },

That is configuration block "forward" is empty. Accordingly, this leads to an update listener every apply.

Relevant Error/Panic Output Snippet

# aws_lb_listener.alb[1] will be updated in-place
  ~ resource "aws_lb_listener" "alb" {
        id                = "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:listener/app/cloud3-lb/397c8400222f6274/c8d08c40ceaf4bc5"
        tags              = {
            "Description" = "am"
            "Name"        = "cloud3-alb-8080"
        }
        # (5 unchanged attributes hidden)

      ~ default_action {
          - target_group_arn = "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:targetgroup/cloud3-alb-tg-8080/fc885ff52dbf1936" -> null
            # (2 unchanged attributes hidden)

          + forward {
              + stickiness {
                  + duration = 86400
                  + enabled  = true
                }
              + target_group {
                  + arn    = "arn:aws:elasticloadbalancing:eu-central-1:<account_id>:targetgroup/cloud3-alb-tg-8080/fc885ff52dbf1936"
                  + weight = 1
                }
            }
        }
    }

Terraform Configuration Files

alb.zip

Steps to Reproduce

unzip alb.zip
terraform workspace new cloud3
terraform init
terraform apply
terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@FlexTickets FlexTickets added the bug Addresses a defect in current functionality. label Aug 13, 2023
@github-actions github-actions bot added the service/elbv2 Issues and PRs that pertain to the elbv2 service. label Aug 13, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Aug 13, 2023
@justinretzolk
Copy link
Member

Related #20200
Possibly Related #14119

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Aug 14, 2023
@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/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
3 participants