diff --git a/main.tf b/main.tf index 118c273..fe11531 100644 --- a/main.tf +++ b/main.tf @@ -264,6 +264,16 @@ resource "aws_security_group" "services_dynamic" { cidr_blocks = ["0.0.0.0/0"] } + dynamic "ingress" { + for_each = lookup(local.services[count.index], "ingress_ports", []) + content { + from_port = ingress.value + to_port = ingress.value + protocol = "tcp" + security_groups = [aws_security_group.services[count.index].id] + } + } + dynamic "ingress" { for_each = [for k, v in var.services : k if k != local.services[count.index].name && @@ -454,13 +464,14 @@ resource "aws_appautoscaling_policy" "this" { service_namespace = aws_appautoscaling_target.this[count.index].service_namespace target_tracking_scaling_policy_configuration { - target_value = lookup(local.services[count.index], "auto_scaling_max_cpu_util", 100) + target_value = lookup(local.services[count.index], "auto_scaling_target_value", 100) scale_in_cooldown = 300 scale_out_cooldown = 300 predefined_metric_specification { - predefined_metric_type = "ECSServiceAverageCPUUtilization" + predefined_metric_type = lookup(local.services[count.index], "auto_scaling_metric_type", "ECSServiceAverageCPUUtilization") + resource_label = "${aws_lb.this[count.index].arn_suffix}/${aws_lb_target_group.this[count.index].arn_suffix}" } } diff --git a/outputs.tf b/outputs.tf index 24e3386..2ee9b7b 100644 --- a/outputs.tf +++ b/outputs.tf @@ -68,6 +68,11 @@ output "application_load_balancers_dns_names" { value = aws_lb.this.*.dns_name } +output "application_load_balancers_listeners_arns" { + description = "List of ARNs of Application Load Balancer Listeners" + value = aws_lb_listener.this.*.arn +} + # SECURITY GROUPS output "web_security_group_arn" {