Skip to content

Commit

Permalink
Merge pull request #6 from brooksClo19/patch-1
Browse files Browse the repository at this point in the history
adding memory based autoscaling
  • Loading branch information
robertomoutinho authored Nov 7, 2023
2 parents fdf24fa + 9edd15b commit 52d01f6
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions autoscaling.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "aws_appautoscaling_target" "target" {
## App Autoscaling Policy ##
############################

resource "aws_appautoscaling_policy" "auto_scaling" {
resource "aws_appautoscaling_policy" "auto_scaling_cpu" {

count = var.enable_asg ? 1 : 0
name = "${var.environment}-${var.name}-cpu-scale"
Expand All @@ -36,4 +36,27 @@ resource "aws_appautoscaling_policy" "auto_scaling" {

depends_on = [aws_appautoscaling_target.target]

}
}

resource "aws_appautoscaling_policy" "auto_scaling_mem" {

count = var.enable_asg ? 1 : 0
name = "${var.environment}-${var.name}-mem-scale"
policy_type = "TargetTrackingScaling"
resource_id = aws_appautoscaling_target.target[0].resource_id
service_namespace = aws_appautoscaling_target.target[0].service_namespace
scalable_dimension = aws_appautoscaling_target.target[0].scalable_dimension

target_tracking_scaling_policy_configuration {
target_value = var.asg_threshold_mem_to_scale_up
scale_in_cooldown = var.asg_cooldown_to_scale_up_again
scale_out_cooldown = var.asg_cooldown_to_scale_up_again

predefined_metric_specification {
predefined_metric_type = "ECSServiceAverageMemoryUtilization"
}
}

depends_on = [aws_appautoscaling_target.target]

}

0 comments on commit 52d01f6

Please sign in to comment.