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

Switch up how targets groups are associated with the ASG #296

Merged
merged 2 commits into from
Mar 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
}