Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 0656d4e

Browse files
author
Michael McGirr
authored
Switch up how targets groups are associated with the ASG (#296)
* Switch up how targets groups are associated with the ASG * Small fix for the tg association in the ASG module
1 parent dad0d84 commit 0656d4e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/asg/main.tf

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ resource "aws_autoscaling_group" "cluster" {
2929
health_check_type = var.health_check_type
3030
launch_configuration = aws_launch_configuration.cluster.name
3131
load_balancers = var.elb_names
32-
target_group_arns = var.alb_target_group_arns
3332
max_size = var.max_nodes
3433
min_size = var.min_nodes
3534
name_prefix = "${var.name_prefix}-${var.name_suffix}"
@@ -111,3 +110,10 @@ resource "aws_launch_configuration" "cluster" {
111110
create_before_destroy = true
112111
}
113112
}
113+
114+
# Attach ASG to the load balancer target group
115+
resource "aws_autoscaling_attachment" "main" {
116+
count = length(var.alb_target_group_arns)
117+
autoscaling_group_name = aws_autoscaling_group.cluster.name
118+
alb_target_group_arn = var.alb_target_group_arns[count.index]
119+
}

0 commit comments

Comments
 (0)