88# Module : AUTOSCALING POLICY UP
99# Description : Provides an AutoScaling Scaling Policy resource.
1010resource "aws_autoscaling_policy" "scale_up" {
11- count = local. autoscaling_enabled ? 1 : 0
11+ count = local. autoscaling_enabled && var . aws_autoscaling_policy_scale_up ? 1 : 0
1212 name = format (" %s%sscale%sup" , module. labels . id , var. delimiter , var. delimiter )
1313 scaling_adjustment = var. scale_up_scaling_adjustment
1414 adjustment_type = var. scale_up_adjustment_type
@@ -20,20 +20,20 @@ resource "aws_autoscaling_policy" "scale_up" {
2020# Module : AUTOSCALING POLICY UP
2121# Description : Provides an AutoScaling Scaling Policy resource.
2222resource "aws_autoscaling_policy" "scale_up_spot" {
23- count = local. spot_autoscaling_enabled ? 1 : 0
23+ count = local. spot_autoscaling_enabled && var . aws_autoscaling_policy_scale_up_spot ? 1 : 0
2424 name = format (" %s%sscale%sup-spot" , module. labels . id , var. delimiter , var. delimiter )
2525 scaling_adjustment = var. scale_up_scaling_adjustment
2626 adjustment_type = var. scale_up_adjustment_type
2727 policy_type = var. scale_up_policy_type
2828 cooldown = var. scale_up_cooldown_seconds
2929 autoscaling_group_name = join (" " , aws_autoscaling_group. spot [* ]. name )
30-
3130}
3231
32+
3333# Module : AUTOSCALING POLICY DOWN
3434# Description : Provides an AutoScaling Scaling Policy resource.
3535resource "aws_autoscaling_policy" "scale_down" {
36- count = local. autoscaling_enabled ? 1 : 0
36+ count = local. autoscaling_enabled && var . aws_autoscaling_policy_scale_down ? 1 : 0
3737 name = format (" %s%sscale%sdown" , module. labels . id , var. delimiter , var. delimiter )
3838 scaling_adjustment = var. scale_down_scaling_adjustment
3939 adjustment_type = var. scale_down_adjustment_type
@@ -45,7 +45,7 @@ resource "aws_autoscaling_policy" "scale_down" {
4545# Module : AUTOSCALING POLICY DOWN
4646# Description : Provides an AutoScaling Scaling Policy resource.
4747resource "aws_autoscaling_policy" "scale_down_spot" {
48- count = local. spot_autoscaling_enabled ? 1 : 0
48+ count = local. spot_autoscaling_enabled && var . aws_autoscaling_policy_scale_down_spot ? 1 : 0
4949 name = format (" %s%sscale%sdown-spot" , module. labels . id , var. delimiter , var. delimiter )
5050 scaling_adjustment = var. scale_down_scaling_adjustment
5151 adjustment_type = var. scale_down_adjustment_type
@@ -57,7 +57,7 @@ resource "aws_autoscaling_policy" "scale_down_spot" {
5757# Module : CLOUDWATCH METRIC ALARM CPU HIGH
5858# Description : Provides a CloudWatch Metric Alarm resource.
5959resource "aws_cloudwatch_metric_alarm" "cpu_high" {
60- count = local. autoscaling_enabled ? 1 : 0
60+ count = local. autoscaling_enabled && var . aws_cloudwatch_metric_alarm_enabled_cpu_high ? 1 : 0
6161 alarm_name = format (" %s%scpu%sutilization%shigh" , module. labels . id , var. delimiter , var. delimiter , var. delimiter )
6262
6363 comparison_operator = " GreaterThanOrEqualToThreshold"
@@ -79,7 +79,7 @@ resource "aws_cloudwatch_metric_alarm" "cpu_high" {
7979# Module : CLOUDWATCH METRIC ALARM CPU HIGH
8080# Description : Provides a CloudWatch Metric Alarm resource.
8181resource "aws_cloudwatch_metric_alarm" "cpu_high_spot" {
82- count = local. spot_autoscaling_enabled ? 1 : 0
82+ count = local. spot_autoscaling_enabled && var . aws_cloudwatch_metric_alarm_enabled_cpu_high_spot ? 1 : 0
8383 alarm_name = format (" %s%scpu%sutilization%shigh-spot" , module. labels . id , var. delimiter , var. delimiter , var. delimiter )
8484
8585 comparison_operator = " GreaterThanOrEqualToThreshold"
@@ -102,7 +102,7 @@ resource "aws_cloudwatch_metric_alarm" "cpu_high_spot" {
102102# Module : CLOUDWATCH METRIC ALARM CPU LOW
103103# Description : Provides a CloudWatch Metric Alarm resource.
104104resource "aws_cloudwatch_metric_alarm" "cpu_low" {
105- count = local. autoscaling_enabled ? 1 : 0
105+ count = local. autoscaling_enabled && var . aws_cloudwatch_metric_alarm_enabled_cpu_low ? 1 : 0
106106 alarm_name = format (" %s%scpu%sutilization%slow" , module. labels . id , var. delimiter , var. delimiter , var. delimiter )
107107 comparison_operator = " LessThanOrEqualToThreshold"
108108 evaluation_periods = var. cpu_utilization_low_evaluation_periods
@@ -124,7 +124,7 @@ resource "aws_cloudwatch_metric_alarm" "cpu_low" {
124124# Module : CLOUDWATCH METRIC ALARM CPU LOW
125125# Description : Provides a CloudWatch Metric Alarm resource.
126126resource "aws_cloudwatch_metric_alarm" "cpu_low_spot" {
127- count = local. spot_autoscaling_enabled ? 1 : 0
127+ count = local. spot_autoscaling_enabled && var . aws_cloudwatch_metric_alarm_enabled_cpu_low_spot ? 1 : 0
128128 alarm_name = format (" %s%scpu%sutilization%slow-spot" , module. labels . id , var. delimiter , var. delimiter , var. delimiter )
129129 comparison_operator = " LessThanOrEqualToThreshold"
130130 evaluation_periods = var. cpu_utilization_low_evaluation_periods
@@ -146,7 +146,7 @@ resource "aws_cloudwatch_metric_alarm" "cpu_low_spot" {
146146# Module : AWS AUTOSCALING SCHEDULE
147147# Description : Provides an AutoScaling Schedule resource.
148148resource "aws_autoscaling_schedule" "scaledown" {
149- count = local. autoscaling_enabled_schedule ? 1 : 0
149+ count = local. autoscaling_enabled_schedule && var . enable_autoscaling_schedule_scale_down ? 1 : 0
150150 autoscaling_group_name = join (" " , aws_autoscaling_group. on_demand [* ]. name )
151151 scheduled_action_name = format (" %s-scheduler-down" , module. labels . id )
152152 min_size = var. min_size_scaledown
@@ -159,7 +159,7 @@ resource "aws_autoscaling_schedule" "scaledown" {
159159# Module : AWS AUTOSCALING SCHEDULE
160160# Description : Provides an AutoScaling Schedule resource.
161161resource "aws_autoscaling_schedule" "scaleup" {
162- count = local. autoscaling_enabled_schedule ? 1 : 0
162+ count = local. autoscaling_enabled_schedule && var . enable_autoscaling_schedule_scale_up ? 1 : 0
163163 autoscaling_group_name = join (" " , aws_autoscaling_group. on_demand [* ]. name )
164164 scheduled_action_name = format (" %s-scheduler-up" , module. labels . id )
165165 max_size = var. max_size_scaleup
@@ -172,7 +172,7 @@ resource "aws_autoscaling_schedule" "scaleup" {
172172# Module : AWS AUTOSCALING SCHEDULE
173173# Description : Provides an AutoScaling Schedule resource.
174174resource "aws_autoscaling_schedule" "spot_scaledown" {
175- count = local . autoscaling_enabled_spot_schedule ? 1 : 0
175+ count = var . enabled && var . spot_enabled && var . enable_autoscaling_schedule_spot_scale_down ? 1 : 0
176176 autoscaling_group_name = join (" " , aws_autoscaling_group. spot [* ]. name )
177177 scheduled_action_name = format (" spot-%s-scheduler-down" , module. labels . id )
178178 min_size = var. spot_min_size_scaledown
@@ -185,7 +185,7 @@ resource "aws_autoscaling_schedule" "spot_scaledown" {
185185# Module : AWS AUTOSCALING SCHEDULE
186186# Description : Provides an AutoScaling Schedule resource.
187187resource "aws_autoscaling_schedule" "spot_scaleup" {
188- count = local . autoscaling_enabled_spot_schedule ? 1 : 0
188+ count = var . enabled && var . spot_enabled && var . enable_autoscaling_schedule_spot_scale_up ? 1 : 0
189189 autoscaling_group_name = join (" " , aws_autoscaling_group. spot [* ]. name )
190190 scheduled_action_name = format (" spot-%s-scheduler-up" , module. labels . id )
191191 max_size = var. spot_max_size
0 commit comments