-
Notifications
You must be signed in to change notification settings - Fork 2
/
scaling.tf
34 lines (29 loc) · 992 Bytes
/
scaling.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
variable "enable_scaling" {
description = "Bool to enable scaling policy"
type = bool
default = true
}
variable "scaling_cpu_utilization" {
description = "The percent CPU utilization for scaling."
type = number
default = 80
}
variable "instance_warmup_time" {
description = "The time in seconds the instance is estimated to require to warm up"
type = number
default = 9000
}
resource "aws_autoscaling_policy" "this" {
count = var.enable_scaling ? 1 : 0
name = "${local.name}-scaling"
adjustment_type = "ChangeInCapacity"
policy_type = "TargetTrackingScaling"
estimated_instance_warmup = var.instance_warmup_time
target_tracking_configuration {
predefined_metric_specification {
predefined_metric_type = "ASGAverageCPUUtilization"
}
target_value = var.scaling_cpu_utilization
}
autoscaling_group_name = module.asg.autoscaling_group_name
}