-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto_scaling.tf
54 lines (53 loc) · 1.7 KB
/
auto_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright © 2023, Oracle and/or its affiliates.
# All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
####################################################################
# Depends on Paid Resource
####################################################################
resource "oci_autoscaling_auto_scaling_configuration" "auto_scaling_configuration" {
count = local.is_scalable ? 1 : 0
compartment_id = local.compartment_ocid
display_name = format("%s-auto-scaling-configuration", var.label_prefix)
auto_scaling_resources {
id = oci_core_instance_pool.instance_pool[0].id
type = "instancePool"
}
policies {
display_name = format("%s-auto-scaling-policy", var.label_prefix)
capacity {
initial = var.compute_instances[local.sizing]
min = var.compute_instances[local.sizing]
max = var.compute_instances[local.sizing] * 3
}
policy_type = "threshold"
rules {
action {
type = "CHANGE_COUNT_BY"
value = "1"
}
display_name = format("%s-auto-scaling-out-rule", var.label_prefix)
metric {
metric_type = "CPU_UTILIZATION"
threshold {
operator = "GT"
value = "80"
}
}
}
rules {
action {
type = "CHANGE_COUNT_BY"
value = "-1"
}
display_name = format("%s-auto-scaling-out-rule", var.label_prefix)
metric {
metric_type = "CPU_UTILIZATION"
threshold {
operator = "LT"
value = "20"
}
}
}
}
cool_down_in_seconds = "300"
depends_on = [oci_core_instance_pool_instance.instance_pool_instance[0]]
}