Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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}"
}
}

Expand Down
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down