Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding memory based autoscaling #6

Merged
merged 1 commit into from
Nov 7, 2023
Merged
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
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]

}
Loading