Skip to content

Commit

Permalink
fix: enable autoscaling (#389)
Browse files Browse the repository at this point in the history
* fix: enable autoscaling

* fix: desired count 1 for non-prod
  • Loading branch information
chris13524 authored Mar 6, 2024
1 parent 2e14118 commit 477700e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion terraform/ecs/cluster.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
locals {
image = "${var.ecr_repository_url}:${var.image_version}"

desired_count = module.this.stage == "prod" ? var.autoscaling_desired_count : 1

task_cpu = module.this.stage == "prod" ? var.task_cpu : 256
task_memory = module.this.stage == "prod" ? var.task_memory : 512

Expand Down Expand Up @@ -175,7 +177,7 @@ resource "aws_ecs_service" "app_service" {
cluster = aws_ecs_cluster.app_cluster.id
task_definition = aws_ecs_task_definition.app_task.arn
launch_type = "FARGATE"
desired_count = var.autoscaling_desired_count
desired_count = local.desired_count
propagate_tags = "TASK_DEFINITION"

# Wait for the service deployment to succeed
Expand Down
6 changes: 3 additions & 3 deletions terraform/ecs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ variable "task_memory" {
variable "autoscaling_desired_count" {
description = "Minimum number of instances in the autoscaling group"
type = number
default = 1
default = 2
}

variable "autoscaling_min_capacity" {
description = "Minimum number of instances in the autoscaling group"
type = number
default = 1
default = 2
}

variable "autoscaling_max_capacity" {
description = "Maximum number of instances in the autoscaling group"
type = number
default = 1
default = 8
}

variable "cloudwatch_logs_key_arn" {
Expand Down

0 comments on commit 477700e

Please sign in to comment.