hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.17k forks source link

`load_balancing_algorithm_type` behaves incorrectly when added/removed. #12297

Open lizthegrey opened 4 years ago

lizthegrey commented 4 years ago

Community Note

Terraform Version

Terraform/0.12.23 TFC/402a0ad321

Provider Version

v2.52.0

Affected Resource(s)

Terraform Configuration Files

First, create:

resource "aws_alb_target_group" "shepherd_alb_tg" {
  name                          = "shepherd-${var.env}-alb-tg"
  target_type                   = "instance"
  load_balancing_algorithm_type = "least_outstanding_requests"
  port                          = 8080
  protocol                      = "HTTP"
  vpc_id                        = var.vpc_id
}

Then roll back to (notice the removed load_balancing_algorithm_type field):

resource "aws_alb_target_group" "shepherd_alb_tg" {
  name        = "shepherd-${var.env}-alb-tg"
  target_type = "instance"
  port        = 8080
  protocol    = "HTTP"
  vpc_id      = var.vpc_id
}

Debug Output

n/a

Panic Output

n/a

Expected Behavior

  # module.kibble_asgs.aws_alb_target_group.shepherd_alb_tg will be updated in-place
  ~ resource "aws_alb_target_group" "shepherd_alb_tg" {
        arn                                = "arn:aws:elasticloadbalancing:us-east-1:702835727665:targetgroup/shepherd-kibble-alb-tg/63d1693fa2fca1b2"
        arn_suffix                         = "targetgroup/shepherd-kibble-alb-tg/63d1693fa2fca1b2"
        deregistration_delay               = 300
        id                                 = "arn:aws:elasticloadbalancing:us-east-1:702835727665:targetgroup/shepherd-kibble-alb-tg/63d1693fa2fca1b2"
        lambda_multi_value_headers_enabled = false
      ~ load_balancing_algorithm_type      = "least_outstanding_requests" -> "round_robin"
        name                               = "shepherd-kibble-alb-tg"
        port                               = 8080
        protocol                           = "HTTP"
        proxy_protocol_v2                  = false
        slow_start                         = 0
        tags                               = {}
        target_type                        = "instance"
        vpc_id                             = "vpc-f1ea198a"
    }

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

Actual Behavior

No changes. Infrastructure is up-to-date.

Steps to Reproduce

  1. terraform apply to create an ALB target group with load_balancing_algorithm_type set to the non-default of least_outstanding_requests
  2. terraform apply to remove the load_balancing_algorithm_type parameter

Important Factoids

n/a

References

nijave commented 4 years ago

Just ran into this. I suspect it's because that field should be using a default instead of being "computed"

                       "load_balancing_algorithm_type": {
                Type:     schema.TypeString,
                Optional: true,
                Computed: true,
                ValidateFunc: validation.StringInSlice([]string{
                    "round_robin",
                    "least_outstanding_requests",
                }, false),
            },
justinretzolk commented 3 years ago

Hey @lizthegrey 👋 Thank you for taking the time to file this! Given that there's been a number of AWS Provider releases since you initially filed it, can you confirm whether you're still experiencing this behavior?

lizthegrey commented 3 years ago

Just ran into this. I suspect it's because that field should be using a default instead of being "computed"

                       "load_balancing_algorithm_type": {
              Type:     schema.TypeString,
              Optional: true,
              Computed: true,
              ValidateFunc: validation.StringInSlice([]string{
                  "round_robin",
                  "least_outstanding_requests",
              }, false),
          },

As per this, I believe because there is still no Default: "round_robin", at https://github.com/hashicorp/terraform-provider-aws/blob/187f1659a4fef11ac314567273b5470afe6b662f/internal/service/elbv2/target_group.go#L132 that the bug still exists and should be reproducible with the repro instructions I gave. However, it is not a priority for us to repro as we are not using least_outstanding_requests and flipping it back and forth at the moment.

github-actions[bot] commented 1 month ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!