module-base-ecs-appasg-ttscaling-predefined
This terraform module creates an ECS Application AutoScaling Target Tracking Scaling Policy with policies predefined and scheduled actions
This resources are only attached to the specific ECS Service, if you remove the
service, this policies and scheduled actions are remove. If you makes changes in ECS Service
which required #force replacement in the ECS Service, this policies an schedule are removed
and you need apply this terraform them again
|
Usage example
Application AutoScaling Target Tracking Scaling Policy: ECSServiceAverageMemoryUtilization and ECSServiceAverageCPUUtilization
module "appasg" {
source = "git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/compute/module-base-ecs-appasg-ttscaling-predefined.git?ref=vX.Y.Z"
aws_region = var.aws_region
prefix = var.prefix
cluster_name = module.cluster.cluster_name
service_name = module.nginx.service_name
target_min_capacity = 2
target_max_capacity = 4
predefined_policy = {
"memory-avg" = {
disable_scale_in = false
target_value = 60
predefined_metric_type = "ECSServiceAverageMemoryUtilization"
scale_in_cooldown = 0
scale_out_cooldown = 0
},
"cpu-avg" = {
disable_scale_in = false
target_value = 80
predefined_metric_type = "ECSServiceAverageCPUUtilization"
scale_in_cooldown = 0
scale_out_cooldown = 0
}
}
tags = {
"Project" = "test"
"Environment" = "basic"
}
}
Application AutoScaling Target Tracking Scaling Policy: ECSServiceAverageMemoryUtilization, ECSServiceAverageCPUUtilization and ALBRequestCountPerTarget
module "appasg" {
source = "git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/compute/module-base-ecs-appasg-ttscaling-predefined.git?ref=vX.Y.Z"
aws_region = var.aws_region
prefix = var.prefix
cluster_name = module.cluster.cluster_name
service_name = module.nginx.service_name
target_min_capacity = 2
target_max_capacity = 4
predefined_policy = {
"memory-avg" = {
disable_scale_in = false
target_value = 60
predefined_metric_type = "ECSServiceAverageMemoryUtilization"
scale_in_cooldown = 300
scale_out_cooldown = 120
},
"cpu-avg" = {
disable_scale_in = false
target_value = 80
predefined_metric_type = "ECSServiceAverageCPUUtilization"
scale_in_cooldown = 300
scale_out_cooldown = 120
}
}
predefined_requests_policy = {
"request-count" = {
disable_scale_in = false
target_value = 1000
load_balancer_arn_suffix = module.alb.alb_arn_suffix
target_group_arn_suffix = module.nginx.target_group_arn_suffix
scale_in_cooldown = 300
scale_out_cooldown = 120
}
}
tags = {
"Project" = "test"
"Environment" = "basic"
}
}
Application AutoScaling Target Tracking Scaling Policy: ECSServiceAverageMemoryUtilization, ECSServiceAverageCPUUtilization and schedulen actions
module "appasg" {
source = "git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/compute/module-base-ecs-appasg-ttscaling-predefined.git?ref=vX.Y.Z"
aws_region = local.aws_region
prefix = local.prefix
cluster_name = module.cluster.cluster_name
service_name = module.nginx.service_name
target_min_capacity = 2
target_max_capacity = 4
predefined_policy = {
"memory-avg" = {
disable_scale_in = false
target_value = 60
predefined_metric_type = "ECSServiceAverageMemoryUtilization"
scale_in_cooldown = 300
scale_out_cooldown = 120
},
"cpu-avg" = {
disable_scale_in = false
target_value = 80
predefined_metric_type = "ECSServiceAverageCPUUtilization"
scale_in_cooldown = 300
scale_out_cooldown = 120
}
}
scheduled_actions = {
"start" = {
scheduled_action_cron = "cron(58 12 ? * MON-FRI *)"
scheduled_action_min_capacity = 2
scheduled_action_max_capacity = 4
},
"stop" = {
scheduled_action_cron = "cron(12 13 ? * MON-FRI *)"
scheduled_action_min_capacity = 0
scheduled_action_max_capacity = 0
},
"weekend-start" = {
scheduled_action_cron = "cron(00 8 ? * SAT *)"
scheduled_action_min_capacity = 0
scheduled_action_max_capacity = 0
},
"weekend-stop" = {
scheduled_action_cron = "cron(00 20 ? * SUN *)"
scheduled_action_min_capacity = 0
scheduled_action_max_capacity = 0
}
}
tags = {
"Project" = "test"
"Environment" = "basic"
}
}
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
AWS Region name where you deploy VPC |
|
n/a |
yes |
|
The Cluster name for all resources |
|
n/a |
yes |
|
A list of objects for create predefined policies for |
|
|
no |
|
A list of objects for create predefined policy for Load Balancer request count per target |
|
|
no |
|
The prefix to be attached to every resource name |
|
n/a |
yes |
|
A list of objects for create scheduled actions for application autoscaling |
|
|
no |
|
The Service name for naming all resources |
|
n/a |
yes |
|
Specific tags for all module resources |
|
n/a |
yes |
|
The max capacity of the scalable target |
|
n/a |
yes |
|
The min capacity of the scalable target |
|
n/a |
yes |