Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
fix: remove autoscaling policy
Browse files Browse the repository at this point in the history
  • Loading branch information
jspark2000 committed Aug 25, 2024
1 parent 5e3679d commit d1219c6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 74 deletions.
1 change: 1 addition & 0 deletions aws/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 0 additions & 74 deletions aws/royals/ecs-api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,77 +100,3 @@ resource "aws_appautoscaling_target" "api" {
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}

resource "aws_appautoscaling_policy" "ecs_policy_up" {
name = "ecs-auto-scaling-policy-up"
policy_type = "StepScaling"
resource_id = aws_appautoscaling_target.api.resource_id
scalable_dimension = aws_appautoscaling_target.api.scalable_dimension
service_namespace = aws_appautoscaling_target.api.service_namespace

step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 60
metric_aggregation_type = "Average"

step_adjustment {
metric_interval_lower_bound = 0
scaling_adjustment = 1
}
}
}

resource "aws_cloudwatch_metric_alarm" "ecs_cpu_utilization_high" {
alarm_name = "ecs-cpu-utilization-high"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "2"
metric_name = "CPUUtilization"
namespace = "AWS/ECS"
period = "60"
statistic = "Average"
threshold = "80"

dimensions = {
ClusterName = aws_ecs_cluster.main.name
ServiceName = aws_ecs_service.main.name
}

alarm_actions = [aws_appautoscaling_policy.ecs_policy_up.arn]
}

resource "aws_appautoscaling_policy" "ecs_policy_down" {
name = "ecs-auto-scaling-policy-down"
policy_type = "StepScaling"
resource_id = aws_appautoscaling_target.api.resource_id
scalable_dimension = aws_appautoscaling_target.api.scalable_dimension
service_namespace = aws_appautoscaling_target.api.service_namespace

step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 60
metric_aggregation_type = "Average"

step_adjustment {
metric_interval_upper_bound = 0
scaling_adjustment = -1
}
}
}

resource "aws_cloudwatch_metric_alarm" "ecs_cpu_utilization_low" {
alarm_name = "ecs-cpu-utilization-low"
comparison_operator = "LessThanThreshold"
evaluation_periods = "2"
metric_name = "CPUUtilization"
namespace = "AWS/ECS"
period = "60"
statistic = "Average"
threshold = "30"

dimensions = {
ClusterName = aws_ecs_cluster.main.name
ServiceName = aws_ecs_service.main.name
}

alarm_actions = [aws_appautoscaling_policy.ecs_policy_down.arn]
}

0 comments on commit d1219c6

Please sign in to comment.