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

ALB register container instances supported? #39

Open
archenroot opened this issue Nov 14, 2019 · 5 comments
Open

ALB register container instances supported? #39

archenroot opened this issue Nov 14, 2019 · 5 comments

Comments

@archenroot
Copy link

archenroot commented Nov 14, 2019

Hi,

I don't see any aws_lb_target_group_attachment resource being used, but it can be hidden somewhere in submodules being used.

Does this module cover registering container instances in ALB target group?

@jamengual
Copy link
Contributor

yes it does.

@nitrocode
Copy link
Member

The alb_ingress module is used in this module which creates aws_lb_target_group and aws_lb_listener_rule resources.
https://github.com/cloudposse/terraform-aws-alb-ingress/blob/master/main.tf

The aws_lb_target_group is passed into the ecs_alb_service_task module using the dictionary var.ecs_load_balancers which then connects the aws_ecs_service to the target group.

https://github.com/cloudposse/terraform-aws-ecs-alb-service-task/blob/master/main.tf#L308

But I don't see a aws_lb_target_group_attachment. Do you @jamengual ?

@BGarber42
Copy link

I came across the same question, the only answer was pretty much this ticket

@nitrocode
Copy link
Member

nitrocode commented Jul 30, 2021

@BGarber42 @archenroot Oh I was mistaken. You do not need a target group attachment. I believe only the listener rule (created by the alb_ingress module) is required as that attaches the target group to the ALB's listener arn.

https://github.com/cloudposse/terraform-aws-alb-ingress/blob/ab6033cc736fa37fc4e65ab897423a438b45e6f5/main.tf#L49-L58

@nitrocode
Copy link
Member

nitrocode commented Jul 1, 2022

I just ran into this again. I'm glad this ticket was written because the above description reminded me that I do not need a specific aws_lb_target_group_attachment.

If you want to create an attachment outside of this module, the following can be done.

module "ecs_web_app" {
  # ...
}

resource "aws_lb_target_group_attachment" "default" {
  target_group_arn = module.ecs_web_app.alb_ingress_target_group_arn

  # Replace with your target_id
  # target_id = null
}

There are very few inputs to this and we could add this as an optional resource within this module but it's unnecessary if you rely on listener rules to direct directly to the LB.

The attachment only seems necessary if the listener rule directs directly to the target group

resource "aws_lb_listener" "default" {
  default_action {
    type             = "forward"
    target_group_arn = module.ecs_web_app.alb_ingress_target_group_arn
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants