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 - header modification on existing listeners is not applied #40986

Open
MatMit opened this issue Jan 17, 2025 · 8 comments · May be fixed by #41299
Open

[Bug]: aws_lb_listener - header modification on existing listeners is not applied #40986

MatMit opened this issue Jan 17, 2025 · 8 comments · May be fixed by #41299
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.

Comments

@MatMit
Copy link

MatMit commented Jan 17, 2025

Terraform Core Version

1.10.4

AWS Provider Version

5.84.0

Affected Resource(s)

When I try to turn off Server header in aws_lb_lisnener using routing_http_response_server_enabled parameter, correct plan is created, but no changes to the listener are done.

Expected Behavior

ALB listener will be modified and Server header value will be changed to Off

Actual Behavior

Server header attribute is not modified. Next plan will still show changes, and still it will be untouched.

Relevant Error/Panic Output Snippet

Terraform Configuration Files

data "aws_vpc" "default" {
  default = true
}

data "aws_subnets" "default" {
    filter {
      name = "vpc-id"
      values = [data.aws_vpc.default.id]
    }
}

resource "aws_lb" "test" {
  name               = "test-lb"
  internal           = false
  load_balancer_type = "application"
  subnets = data.aws_subnets.default.ids
}

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

  routing_http_response_server_enabled = false

  default_action {
    type             = "fixed-response"
    
    fixed_response {
      content_type = "text/plain"
      message_body = "OK"
      status_code = "200"
    }
  }
}
  # aws_lb_listener.test will be updated in-place
  ~ resource "aws_lb_listener" "test" {
        id                                                                  = "arn:aws:elasticloadbalancing:us-east-1:<account-id>:listener/app/test-lb/<id>"
      ~ routing_http_response_server_enabled                                = true -> false
        tags                                                                = {}
        # (16 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

And there is this warning in logs:

{"@level":"warn","@message":"Provider \"provider[\\\"registry.terraform.io/hashicorp/aws\\\"]\" produced an unexpected new value for aws_lb_listener.test, but we are tolerating it because it is using the legacy plugin SDK.\n    The following problems may be the cause of any confusing errors from downstream operations:\n      - .routing_http_response_server_enabled: was cty.False, but now cty.True","@timestamp":"2025-01-17T12:58:04.550456+01:00"}

apply log

Steps to Reproduce

  1. Create ALB without routing_http_response_server_enabled parameter used. Please note, that in my example in this step I used version 5.76.0
  2. Update provider hashicorp/aws to version 5.84.0
  3. Set routing_http_response_server_enabled = false
  4. Apply changes
  5. Verify listener attributes. There should be no changes. You could also create another plan. It will once again try to modify header once again.

I also created respository with example available here

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

@MatMit MatMit added the bug Addresses a defect in current functionality. label Jan 17, 2025
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.

@github-actions github-actions bot added service/elbv2 Issues and PRs that pertain to the elbv2 service. needs-triage Waiting for first response or review from a maintainer. service/vpc Issues and PRs that pertain to the vpc service. labels Jan 17, 2025
@ekirmayer-sam
Copy link

Saw this as well. It will update only on new creation and recreate.

@nathanbowang
Copy link

nathanbowang commented Jan 21, 2025

Have the same issue

@justinretzolk justinretzolk removed needs-triage Waiting for first response or review from a maintainer. service/vpc Issues and PRs that pertain to the vpc service. labels Jan 23, 2025
@oycyc
Copy link
Contributor

oycyc commented Jan 24, 2025

Reacted with a 👍 - having the same issue here.

@cssoftware-main
Copy link

Also encountering this. Current workaround is to taint the listener and then recreate. but this is not desirable.

@pedrofurlanetto90
Copy link

Having the same issue here. Any update on this?

@JonCaine-Sophos
Copy link

Same issue here.
Also discovered that setting the HSTS header doesn't work on existing listeners either. Looks like all header support added by #40736 doesn't work for existing listeners.

mkdewidar added a commit to mkdewidar/terraform-provider-aws that referenced this issue Feb 9, 2025
PR hashicorp#40736 added support for many new listener attributes, however the
resource update code was only written to call ModifyListenerAttributes if
the tcp_idle_timeout_seconds attribute had been updated. This would
result in the terraform plan saying that it would update the attributes,
but the change would not actually get applied.

This change fixes that by making it so that ModifyListenerAttributes is
called whenever any of the attributes has been changed.

Fixes issue hashicorp#40986.
mkdewidar added a commit to mkdewidar/terraform-provider-aws that referenced this issue Feb 9, 2025
PR hashicorp#40736 added support for many new listener attributes, however the
resource update code was only written to call ModifyListenerAttributes if
the tcp_idle_timeout_seconds attribute had been updated. This would
result in the terraform plan saying that it would update the attributes,
but the change would not actually get applied.

This change fixes that by making it so that ModifyListenerAttributes is
called whenever any of the attributes has been changed.

Fixes issue hashicorp#40986.
@mkdewidar mkdewidar linked a pull request Feb 9, 2025 that will close this issue
@mkdewidar
Copy link

I have raised #41299 to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

9 participants