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

8.3.0 alb target group stickiness not working. #275

Closed
1 task
tjdgus1912 opened this issue Feb 8, 2023 · 10 comments · Fixed by #277
Closed
1 task

8.3.0 alb target group stickiness not working. #275

tjdgus1912 opened this issue Feb 8, 2023 · 10 comments · Fixed by #277

Comments

@tjdgus1912
Copy link

Description

Please provide a clear and concise description of the issue you are encountering, and a reproduction of your configuration (see the examples/* directory for references that you can copy+paste and tailor to match your configs if you are unable to copy your exact configuration). The reproduction MUST be executable by running terraform init && terraform apply without any further changes.

If your request is for a new feature, please use the Feature request template.

  • ✋ I have searched the open/closed issues and my issue is not listed.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

  • Module version [Required]: 8.3.0

  • Terraform version: 1.3.6

  • Provider version(s): 4.52.0

Reproduction Code [Required]

target_groups spec
[{
backend_port = "${v.backend_port}"
backend_protocol = "${v.backend_protocol}"
deregistration_delay = 60
protocol_version = "HTTP1"
target_type = "instance"
targets = { for target_id in (var.ec2 > 0 ? module.ec2.*.id : v.target_ids) :
target_id => {
"target_id" = "${target_id}"
"port" = "${v.backend_port}"
}
}
health_check = {
enabled = true
interval = 30
path = "${v.backend_health_check_path}"
port = "traffic-port"
healthy_threshold = 2
unhealthy_threshold = 3
timeout = 10
protocol = "HTTP"
matcher = "200-399"
}
load_balancing_algorithm_type = v.lb_algorithm_type
stickiness = v.stickiness
}]

Steps to reproduce the behavior:

use 8.3.0 version
source = "terraform-aws-modules/alb/aws"
version = "8.3.0"

Expected behavior

alb create success

Actual behavior

Terminal Output Screenshot(s)

image

guess problem

part of main.tf(8.3.0)
dynamic "stickiness" {
for_each = try([var.target_groups[count.index].stickiness], [])

content {
  enabled         = lookup(stickiness.value.enabled, null)
  cookie_duration = lookup(stickiness.value.cookie_duration, null)
  type            = lookup(stickiness.value.type, null)
  cookie_name     = lookup(stickiness.value.cookie_name, null)
}

}

I think you should replace lookup with try.

@bryantbiggs
Copy link
Member

Its hard to say from the info you have provided, you don't provide a full reproduction or even the values for stickiness used, but the type is required which is what the error message is stating https://github.com/hashicorp/terraform-provider-aws/blob/8991a74b045c6e3b99b2204e6cf91c5a700cdd9e/internal/service/elbv2/target_group.go#L257

changing the lookup() to a try() won't have any affect

@Reversaidx
Copy link

+1 the same error

@plp-jordann-collin
Copy link

plp-jordann-collin commented Feb 8, 2023

Today, I have the same problem.

module "loadbalancer" {
  source  = "terraform-aws-modules/alb/aws"
  version = "~> 8.X.0"

  name = "test"

  vpc_id          = var.vpc_id
  subnets         = var.subnet_ids
  security_groups = [module.security-group.security_group_id]

  http_tcp_listeners = [
    {
      port               = 80
      protocol           = "HTTP"
      target_group_index = 0
    }
  ]

  target_groups = [
    {
      name = "test"

      backend_protocol = "HTTP"
      backend_port     = 80

      target_type = "instance"

      stickiness = {
        enabled = true

        type            = "lb_cookie"
        cookie_duration = 86400 # 1 day
      }
    }
  ]
}

With module in version 8.3.0, I have the error...
With last 8.2, no error.

I don't understand why it doesn't pass the true to enabled...

@bryantbiggs
Copy link
Member

@jcollin-zmg thanks for the reproduction, I'll look into this now

@antonbabenko
Copy link
Member

This issue has been resolved in version 8.3.1 🎉

@rubenesda
Copy link

Only to clarify, this wasn't solved in version 8.3.1. The issue could have been solved for NLB but ALB has the same problem. This is adding and attaching another security group, which, shouldn't be created.

@bryantbiggs
Copy link
Member

Only to clarify, this wasn't solved in version 8.3.1. The issue could have been solved for NLB but ALB has the same problem. This is adding and attaching another security group, which, shouldn't be created.

That is what was intended so I believe it is working as intended

@rubenesda
Copy link

Not yet. This happened to me today, it created extra security without declared inbound rules and it attached to ALB existing, which, already had a security group created and attached.

@jcolfej
Copy link

jcolfej commented Feb 14, 2023

@rubenesda This is what I explained in the MR that added this feature. #273 (comment) #273 (comment)
You have to modify, everywhere you used the module, to add create_security_group = false...

@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 Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
7 participants