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]: Can't apply aws_globalaccelerator_endpoint_group resource after modifying the weight #31254

Closed
taisytran opened this issue May 8, 2023 · 8 comments · Fixed by #31767
Closed
Labels
bug Addresses a defect in current functionality. service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service.
Milestone

Comments

@taisytran
Copy link

Terraform Core Version

1.3.7

AWS Provider Version

4.56.0

Affected Resource(s)

aws_globalaccelerator_endpoint_group

Expected Behavior

The weight's value can be applied after modifying

Actual Behavior

The weight's value couldn't be applied after modifying

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

...

Steps to Reproduce

  1. Create a aws_globalaccelerator_endpoint_group resource.
  2. Add 2 endpoint_configuration blocks
  3. Set weight the first block is 0 and the second block is 100
  4. Run TF plan and hit TF Apply the plan (1st time)
  5. After applying, modify the first block is 100 and the second is 0
  6. Run TF plan and hit TF Apply again (2nd time)
  7. After applying, Run TF plan again (3rd time), the changes of aws_globalaccelerator_endpoint_group still be there (couldn't be applied)

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@taisytran taisytran added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels May 8, 2023
@github-actions github-actions bot added the service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service. label May 8, 2023
@github-actions
Copy link

github-actions bot commented May 8, 2023

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.

@justinretzolk
Copy link
Member

Hey @taisytran 👋 Thank you for taking the time to raise this! So that we have the necessary information in order to look into this, can you supply a sample Terraform configuration as well as debug logs (redacted as needed)?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels May 9, 2023
@taisytran
Copy link
Author

Hey @taisytran 👋 Thank you for taking the time to raise this! So that we have the necessary information in order to look into this, can you supply a sample Terraform configuration as well as debug logs (redacted as needed)?

Thank you for your support. Here is my TF configuration

terraform {
  required_version = ">= 0.13"
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "~> 4.56.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

resource "aws_globalaccelerator_accelerator" "ga" {
  name            = "my-ga"
  ip_address_type = "IPV4"
  enabled         = true

  attributes {...}
}

resource "aws_globalaccelerator_listener" "ga_listenner" {
  accelerator_arn = aws_globalaccelerator_accelerator.ga.id
  client_affinity = "NONE"
  protocol        = "TCP"

  port_range {
    from_port = 443
    to_port   = 443
  }
  port_range {
    from_port = 80
    to_port   = 80
  }
}

resource "aws_lb" "old_alb" {...}
resource "aws_lb" "new_alb" {...}

resource "aws_globalaccelerator_endpoint_group" "ga_endpoint" {
  listener_arn      = aws_globalaccelerator_listener.ga_listenner.id
  health_check_port = "443"

  endpoint_configuration {
    client_ip_preservation_enabled = true
    endpoint_id = aws_lb.old_alb.arn
    weight      = "0"
  }

  endpoint_configuration {
    client_ip_preservation_enabled = true
    endpoint_id = aws_lb.new_alb.arn
    weight      = "100"
  }
}

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label May 15, 2023
@gagan-eg
Copy link

We are having possibly a similar issue. It seems that if the weight for an endpoint is set to 0 it is dropped API call to aws. I checked the Cloud Trail and with a weight of 0 in an endpoint configuration, I keep seeing

        "endpointConfigurations": [
            {
                "endpointId": "some_arn",
                "clientIPPreservationEnabled": false
>>>>>> (No weight field which in TF state file is 0. This causes weight to get set to 128 instead of 0.
            },
            {
                "endpointId": "some other arn",
                "weight": 100,
                "clientIPPreservationEnabled": false
            }
        ],

@gagan-eg
Copy link

Just as an update, It seems when this happens when you add a new endpoint in an endpoint group with its weight set to 0.

@yannrouillard
Copy link
Contributor

yannrouillard commented Jun 5, 2023

I confirm this bug, a weight of 0 is ignored, it seems to be caused by this line:

if v, ok := tfMap["weight"].(int); ok && v != 0 {

As a result, as no weight is sent in the API call, the value of 128 is used by AWS instead of 0 when creating a new endpoint configuration (which is kind of unexpected)

@github-actions
Copy link

github-actions bot commented Jun 9, 2023

This functionality has been released in v5.2.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!

@github-actions
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 Jul 10, 2023
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/globalaccelerator Issues and PRs that pertain to the globalaccelerator service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants