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

Commit

Permalink
Switch up how targets groups are associated with the ASG (#296)
Browse files Browse the repository at this point in the history
* Switch up how targets groups are associated with the ASG

* Small fix for the tg association in the ASG module
  • Loading branch information
Michael McGirr authored Mar 31, 2020
1 parent dad0d84 commit 0656d4e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/asg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ resource "aws_autoscaling_group" "cluster" {
health_check_type = var.health_check_type
launch_configuration = aws_launch_configuration.cluster.name
load_balancers = var.elb_names
target_group_arns = var.alb_target_group_arns
max_size = var.max_nodes
min_size = var.min_nodes
name_prefix = "${var.name_prefix}-${var.name_suffix}"
Expand Down Expand Up @@ -111,3 +110,10 @@ resource "aws_launch_configuration" "cluster" {
create_before_destroy = true
}
}

# Attach ASG to the load balancer target group
resource "aws_autoscaling_attachment" "main" {
count = length(var.alb_target_group_arns)
autoscaling_group_name = aws_autoscaling_group.cluster.name
alb_target_group_arn = var.alb_target_group_arns[count.index]
}

0 comments on commit 0656d4e

Please sign in to comment.