Skip to content

Commit

Permalink
Add max and min capacity for future autoscaling options
Browse files Browse the repository at this point in the history
  • Loading branch information
alismx committed Oct 17, 2024
1 parent 27d72e8 commit e0393f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions terraform/modules/ecs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ No modules.
| [aws_alb_listener.http](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/alb_listener) | resource |
| [aws_alb_listener_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/alb_listener_rule) | resource |
| [aws_alb_target_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/alb_target_group) | resource |
| [aws_appautoscaling_policy.ecs_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appautoscaling_policy) | resource |
| [aws_appautoscaling_target.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appautoscaling_target) | resource |
| [aws_appmesh_mesh.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appmesh_mesh) | resource |
| [aws_appmesh_virtual_node.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appmesh_virtual_node) | resource |
| [aws_cloudwatch_log_group.ecs_cloudwatch_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
Expand Down
21 changes: 14 additions & 7 deletions terraform/modules/ecs/_local.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ locals {
short_name = "ecrv",
fargate_cpu = 1024,
fargate_memory = 2048,
app_count = 1
min_capacity = 1
max_capacity = 5
app_image = var.disable_ecr == false ? "${terraform.workspace}-ecr-viewer" : "ecr-viewer",
app_version = var.phdi_version,
container_port = 3000,
Expand Down Expand Up @@ -60,7 +61,8 @@ locals {
short_name = "fhirc",
fargate_cpu = 1024,
fargate_memory = 2048,
app_count = 1
min_capacity = 1
max_capacity = 5
app_image = var.disable_ecr == false ? "${terraform.workspace}-fhir-converter" : "fhir-converter",
app_version = var.phdi_version,
container_port = 8080,
Expand All @@ -73,7 +75,8 @@ locals {
short_name = "inge",
fargate_cpu = 1024,
fargate_memory = 2048,
app_count = 1
min_capacity = 1
max_capacity = 5
app_image = var.disable_ecr == false ? "${terraform.workspace}-ingestion" : "ingestion",
app_version = var.phdi_version,
container_port = 8080,
Expand All @@ -86,7 +89,8 @@ locals {
short_name = "vali",
fargate_cpu = 1024,
fargate_memory = 2048,
app_count = 1
min_capacity = 1
max_capacity = 5
app_image = var.disable_ecr == false ? "${terraform.workspace}-validation" : "validation",
app_version = var.phdi_version,
container_port = 8080,
Expand All @@ -99,7 +103,8 @@ locals {
short_name = "trigcr",
fargate_cpu = 1024,
fargate_memory = 2048,
app_count = 1
min_capacity = 1
max_capacity = 5
app_image = var.disable_ecr == false ? "${terraform.workspace}-trigger-code-reference" : "trigger-code-reference",
app_version = var.phdi_version,
container_port = 8080,
Expand All @@ -112,7 +117,8 @@ locals {
short_name = "msgp",
fargate_cpu = 1024,
fargate_memory = 2048,
app_count = 1
min_capacity = 1
max_capacity = 5
app_image = var.disable_ecr == false ? "${terraform.workspace}-message-parser" : "message-parser",
app_version = var.phdi_version,
container_port = 8080,
Expand All @@ -125,7 +131,8 @@ locals {
short_name = "orch",
fargate_cpu = 1024,
fargate_memory = 2048,
app_count = 1
min_capacity = 1
max_capacity = 5
app_image = var.disable_ecr == false ? "${terraform.workspace}-orchestration" : "orchestration",
app_version = var.phdi_version,
container_port = 8080,
Expand Down
7 changes: 6 additions & 1 deletion terraform/modules/ecs/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resource "aws_ecs_service" "this" {
name = each.key
cluster = aws_ecs_cluster.dibbs_app_cluster.id
task_definition = each.value.arn
desired_count = local.service_data[each.key].app_count
desired_count = local.service_data[each.key].min_capacity
launch_type = "FARGATE"

scheduling_strategy = "REPLICA"
Expand Down Expand Up @@ -108,5 +108,10 @@ resource "aws_ecs_service" "this" {
}
}
}

lifecycle {
ignore_changes = [desired_count]
}

tags = local.tags
}

0 comments on commit e0393f9

Please sign in to comment.