@@ -20,12 +20,12 @@ resource "aws_iam_role_policy" "ecs_autoscale_role_policy" {
2020resource "aws_cloudwatch_metric_alarm" "cpu_high" {
2121 alarm_name = " ${ var . name_preffix } -cpu-high"
2222 comparison_operator = " GreaterThanOrEqualToThreshold"
23- evaluation_periods = " 3 "
23+ evaluation_periods = var . max_cpu_evaluation_period
2424 metric_name = " CPUUtilization"
2525 namespace = " AWS/ECS"
26- period = " 60 "
26+ period = var . max_cpu_period
2727 statistic = " Maximum"
28- threshold = " 85 "
28+ threshold = var . max_cpu_threshold
2929 dimensions = {
3030 ClusterName = var.ecs_cluster_name
3131 ServiceName = aws_ecs_service.service.name
@@ -39,12 +39,12 @@ resource "aws_cloudwatch_metric_alarm" "cpu_high" {
3939resource "aws_cloudwatch_metric_alarm" "cpu_low" {
4040 alarm_name = " ${ var . name_preffix } -cpu-low"
4141 comparison_operator = " LessThanOrEqualToThreshold"
42- evaluation_periods = " 3 "
42+ evaluation_periods = var . min_cpu_evaluation_period
4343 metric_name = " CPUUtilization"
4444 namespace = " AWS/ECS"
45- period = " 60 "
45+ period = var . min_cpu_period
4646 statistic = " Average"
47- threshold = " 10 "
47+ threshold = var . min_cpu_threshold
4848 dimensions = {
4949 ClusterName = var.ecs_cluster_name
5050 ServiceName = aws_ecs_service.service.name
@@ -100,6 +100,6 @@ resource "aws_appautoscaling_target" "scale_target" {
100100 resource_id = " service/${ var . ecs_cluster_name } /${ aws_ecs_service . service . name } "
101101 scalable_dimension = " ecs:service:DesiredCount"
102102 role_arn = aws_iam_role. ecs_autoscale_role . arn
103- min_capacity = 1
104- max_capacity = 5
103+ min_capacity = var . scale_target_min_capacity
104+ max_capacity = var . scale_target_max_capacity
105105}
0 commit comments