diff --git a/Modules/AWS/ALB/main.tf b/Modules/AWS/ALB/main.tf index 9c8ca3e..8cefe0f 100644 --- a/Modules/AWS/ALB/main.tf +++ b/Modules/AWS/ALB/main.tf @@ -18,7 +18,7 @@ resource "aws_alb_target_group" "alb_target_group" { protocol = "HTTP" vpc_id = var.vpc_id target_type = "instance" - deregistration_delay = 5 + deregistration_delay = 30 health_check { path = var.alb_health_check_path diff --git a/Modules/AWS/ECS/main.tf b/Modules/AWS/ECS/main.tf index 9edc552..239464f 100644 --- a/Modules/AWS/ECS/main.tf +++ b/Modules/AWS/ECS/main.tf @@ -19,11 +19,12 @@ resource "aws_ecs_task_definition" "ecs_task_definition" { container_definitions = jsonencode([ { - name = "dutymate-container", - image = "${var.ecr_repository_url}:latest", - memory = 768, - cpu = 512, - essential = true, + name = "dutymate-container", + image = "${var.ecr_repository_url}:latest", + cpu = 512, + memoryReservation = 512, + memory = 768, + essential = true, portMappings = [{ containerPort = 8080, hostPort = 8080, @@ -59,6 +60,16 @@ resource "aws_ecs_service" "ecs_service" { deployment_minimum_healthy_percent = 50 deployment_maximum_percent = 100 + capacity_provider_strategy { + capacity_provider = aws_ecs_capacity_provider.capacity_provider.name + base = 2 + weight = 1 + } + + placement_constraints { + type = "distinctInstance" + } + load_balancer { target_group_arn = var.alb_target_group_arn container_port = 8080 @@ -143,10 +154,10 @@ resource "aws_ecs_capacity_provider" "capacity_provider" { managed_termination_protection = "ENABLED" managed_scaling { + status = "ENABLED" + target_capacity = 90 maximum_scaling_step_size = 5 minimum_scaling_step_size = 1 - status = "ENABLED" - target_capacity = 100 } }