umotif-public/terraform-aws-alb

Incorrect attribute value type for alb security group

Closed this issue · 3 comments

What is the current behavior?
It failed to initialise terraform working directory with the following error message:

Error: Incorrect attribute value type
│ 
│   on .terraform/modules/futureverse-oidc.alb/main.tf line 7, in resource "aws_lb" "main":
│    7:   security_groups    = aws_security_group.main[0].id
│     ├────────────────
│     │ aws_security_group.main[0].id is "sg-xxxxe744af24fxxxx"
│ 
│ Inappropriate value for attribute "security_groups": set of string required.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Trying to create a module using example provided:

module "alb" {
  source = "../../"

  name_prefix = "complete-alb-example"

  load_balancer_type = "application"

  internal = false
  vpc_id   = data.aws_vpc.default.id
  subnets  = data.aws_subnets.all.ids

  enable_http_to_https_redirect = true
  cidr_blocks_redirect          = ["10.10.0.0/16"]

  tags = {
    Project = "Test"
  }
}

What is the expected behavior?
The value for attribute alb.security_groups should be a set/array of security groups rather than the first offset.

Software versions?
v2.2.0

this fixed in Fix security groups value #10

@pabloandres13 @Ohid25
I wonder if the ALB security groups need to accept a full array/set of security groups? I can see that the module accepts only the first security group by using main[0].id.
We lost the association with other security groups. And my PR at #12 was closed.
Please take a look at this issue as we are also depending on this module.

@realfredlai i think you are right, maybe we should rollback to the previous version with:
main.*.id instead of using the first one.

Try to create a new issue an open a pull request, an explain your use case.

Using main[0].id limits everything to the first one! So if your case you need all of them and that is valid use case.