Skip to content

Commit c1142ee

Browse files
authored
Merge pull request #20 from AndrewFarley/bugfix-formatting-description-variables
Bugfix: Fixing variable formatting issue, flooring all variables
2 parents ea7cbd2 + dad79ff commit c1142ee

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

alarms.tf

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
locals {
22
thresholds = {
3-
FreeStorageSpaceThreshold = max(var.free_storage_space_threshold, 0)
4-
FreeStorageSpaceTotalThreshold = max(var.free_storage_space_total_threshold, 0)
5-
MinimumAvailableNodes = max(var.min_available_nodes, 0)
6-
CPUUtilizationThreshold = min(max(var.cpu_utilization_threshold, 0), 100)
7-
JVMMemoryPressureThreshold = min(max(var.jvm_memory_pressure_threshold, 0), 100)
8-
MasterCPUUtilizationThreshold = min(max(coalesce(var.master_cpu_utilization_threshold, var.cpu_utilization_threshold), 0), 100)
9-
MasterJVMMemoryPressureThreshold = min(max(coalesce(var.master_jvm_memory_pressure_threshold, var.jvm_memory_pressure_threshold), 0), 100)
3+
FreeStorageSpaceThreshold = floor(max(var.free_storage_space_threshold, 0))
4+
FreeStorageSpaceTotalThreshold = floor(max(var.free_storage_space_total_threshold, 0))
5+
MinimumAvailableNodes = floor(max(var.min_available_nodes, 0))
6+
CPUUtilizationThreshold = floor(min(max(var.cpu_utilization_threshold, 0), 100))
7+
JVMMemoryPressureThreshold = floor(min(max(var.jvm_memory_pressure_threshold, 0), 100))
8+
MasterCPUUtilizationThreshold = floor(min(max(coalesce(var.master_cpu_utilization_threshold, var.cpu_utilization_threshold), 0), 100))
9+
MasterJVMMemoryPressureThreshold = floor(min(max(coalesce(var.master_jvm_memory_pressure_threshold, var.jvm_memory_pressure_threshold), 0), 100))
1010
}
1111
}
1212

@@ -21,7 +21,7 @@ resource "aws_cloudwatch_metric_alarm" "cluster_status_is_red" {
2121
period = var.alarm_cluster_status_is_red_period
2222
statistic = "Maximum"
2323
threshold = "1"
24-
alarm_description = "Average elasticsearch cluster status is in red over last ${var.alarm_cluster_status_is_red_periods * var.alarm_cluster_status_is_red_period / 60} minute(s)"
24+
alarm_description = "Average elasticsearch cluster status is in red over last ${floor(var.alarm_cluster_status_is_red_periods * var.alarm_cluster_status_is_red_period / 60)} minute(s)"
2525
alarm_actions = [local.aws_sns_topic_arn]
2626
ok_actions = [local.aws_sns_topic_arn]
2727
treat_missing_data = "ignore"
@@ -44,7 +44,7 @@ resource "aws_cloudwatch_metric_alarm" "cluster_status_is_yellow" {
4444
period = var.alarm_cluster_status_is_yellow_period
4545
statistic = "Maximum"
4646
threshold = "1"
47-
alarm_description = "Average elasticsearch cluster status is in yellow over last ${var.alarm_cluster_status_is_yellow_periods * var.alarm_cluster_status_is_yellow_period / 60} minute(s)"
47+
alarm_description = "Average elasticsearch cluster status is in yellow over last ${floor(var.alarm_cluster_status_is_yellow_periods * var.alarm_cluster_status_is_yellow_period / 60)} minute(s)"
4848
alarm_actions = [local.aws_sns_topic_arn]
4949
ok_actions = [local.aws_sns_topic_arn]
5050
treat_missing_data = "ignore"
@@ -67,7 +67,7 @@ resource "aws_cloudwatch_metric_alarm" "free_storage_space_too_low" {
6767
period = var.alarm_free_storage_space_too_low_period
6868
statistic = "Minimum"
6969
threshold = local.thresholds["FreeStorageSpaceThreshold"]
70-
alarm_description = "Minimum free disk space on a single node under ${local.thresholds["FreeStorageSpaceThreshold"]}MB for the last ${var.alarm_free_storage_space_too_low_periods * var.alarm_free_storage_space_too_low_period / 60} minute(s)"
70+
alarm_description = "Minimum free disk space on a single node under ${local.thresholds["FreeStorageSpaceThreshold"]}MB for the last ${floor(var.alarm_free_storage_space_too_low_periods * var.alarm_free_storage_space_too_low_period / 60)} minute(s)"
7171
alarm_actions = [local.aws_sns_topic_arn]
7272
ok_actions = [local.aws_sns_topic_arn]
7373
treat_missing_data = "ignore"
@@ -91,7 +91,7 @@ resource "aws_cloudwatch_metric_alarm" "free_storage_space_total_too_low" {
9191
period = var.alarm_free_storage_space_total_too_low_period
9292
statistic = "Sum"
9393
threshold = local.thresholds["FreeStorageSpaceTotalThreshold"]
94-
alarm_description = "Total aggregate free disk space under ${local.thresholds["FreeStorageSpaceTotalThreshold"]}MB for the last ${var.alarm_free_storage_space_total_too_low_periods * var.alarm_free_storage_space_total_too_low_period / 60} minute(s)"
94+
alarm_description = "Total aggregate free disk space under ${local.thresholds["FreeStorageSpaceTotalThreshold"]}MB for the last ${floor(var.alarm_free_storage_space_total_too_low_periods * var.alarm_free_storage_space_total_too_low_period / 60)} minute(s)"
9595
alarm_actions = [local.aws_sns_topic_arn]
9696
ok_actions = [local.aws_sns_topic_arn]
9797
treat_missing_data = "ignore"
@@ -116,7 +116,7 @@ resource "aws_cloudwatch_metric_alarm" "cluster_index_writes_blocked" {
116116
period = var.alarm_cluster_index_writes_blocked_period
117117
statistic = "Maximum"
118118
threshold = "1"
119-
alarm_description = "Elasticsearch index writes being blocker over last ${var.alarm_cluster_index_writes_blocked_periods * var.alarm_cluster_index_writes_blocked_period / 60} minute(s)"
119+
alarm_description = "Elasticsearch index writes being blocker over last ${floor(var.alarm_cluster_index_writes_blocked_periods * var.alarm_cluster_index_writes_blocked_period / 60)} minute(s)"
120120
alarm_actions = [local.aws_sns_topic_arn]
121121
ok_actions = [local.aws_sns_topic_arn]
122122
treat_missing_data = "ignore"
@@ -139,7 +139,7 @@ resource "aws_cloudwatch_metric_alarm" "insufficient_available_nodes" {
139139
period = var.alarm_min_available_nodes_period
140140
statistic = "Minimum"
141141
threshold = local.thresholds["MinimumAvailableNodes"]
142-
alarm_description = "Elasticsearch nodes minimum < ${local.thresholds["MinimumAvailableNodes"]} for ${var.alarm_min_available_nodes_periods * var.alarm_min_available_nodes_period / 60} minutes(s)"
142+
alarm_description = "Elasticsearch nodes minimum < ${local.thresholds["MinimumAvailableNodes"]} for ${floor(var.alarm_min_available_nodes_periods * var.alarm_min_available_nodes_period / 60)} minutes(s)"
143143
alarm_actions = [local.aws_sns_topic_arn]
144144
ok_actions = [local.aws_sns_topic_arn]
145145
treat_missing_data = "ignore"
@@ -162,7 +162,7 @@ resource "aws_cloudwatch_metric_alarm" "automated_snapshot_failure" {
162162
period = var.alarm_automated_snapshot_failure_period
163163
statistic = "Maximum"
164164
threshold = "1"
165-
alarm_description = "Elasticsearch automated snapshot failed over last ${var.alarm_automated_snapshot_failure_periods * var.alarm_automated_snapshot_failure_period / 60} minute(s)"
165+
alarm_description = "Elasticsearch automated snapshot failed over last ${floor(var.alarm_automated_snapshot_failure_periods * var.alarm_automated_snapshot_failure_period / 60)} minute(s)"
166166
alarm_actions = [local.aws_sns_topic_arn]
167167
ok_actions = [local.aws_sns_topic_arn]
168168
treat_missing_data = "ignore"
@@ -185,7 +185,7 @@ resource "aws_cloudwatch_metric_alarm" "cpu_utilization_too_high" {
185185
period = var.alarm_cpu_utilization_too_high_period
186186
statistic = "Average"
187187
threshold = local.thresholds["CPUUtilizationThreshold"]
188-
alarm_description = "Average elasticsearch cluster CPU utilization above ${local.thresholds["CPUUtilizationThreshold"]} over last ${var.alarm_cpu_utilization_too_high_periods * var.alarm_cpu_utilization_too_high_period / 60} minute(s) too high"
188+
alarm_description = "Average elasticsearch cluster CPU utilization above ${local.thresholds["CPUUtilizationThreshold"]} over last ${floor(var.alarm_cpu_utilization_too_high_periods * var.alarm_cpu_utilization_too_high_period / 60)} minute(s) too high"
189189
alarm_actions = [local.aws_sns_topic_arn]
190190
ok_actions = [local.aws_sns_topic_arn]
191191
tags = var.tags
@@ -207,7 +207,7 @@ resource "aws_cloudwatch_metric_alarm" "jvm_memory_pressure_too_high" {
207207
period = var.alarm_jvm_memory_pressure_too_high_period
208208
statistic = "Maximum"
209209
threshold = local.thresholds["JVMMemoryPressureThreshold"]
210-
alarm_description = "Elasticsearch JVM memory pressure is over ${local.thresholds["JVMMemoryPressureThreshold"]} over the last ${var.alarm_jvm_memory_pressure_too_high_periods * var.alarm_jvm_memory_pressure_too_high_period / 60} minute(s)"
210+
alarm_description = "Elasticsearch JVM memory pressure is over ${local.thresholds["JVMMemoryPressureThreshold"]} over the last ${floor(var.alarm_jvm_memory_pressure_too_high_periods * var.alarm_jvm_memory_pressure_too_high_period / 60)} minute(s)"
211211
alarm_actions = [local.aws_sns_topic_arn]
212212
ok_actions = [local.aws_sns_topic_arn]
213213
tags = var.tags
@@ -229,7 +229,7 @@ resource "aws_cloudwatch_metric_alarm" "master_cpu_utilization_too_high" {
229229
period = var.alarm_master_cpu_utilization_too_high_period
230230
statistic = "Average"
231231
threshold = local.thresholds["MasterCPUUtilizationThreshold"]
232-
alarm_description = "Average elasticsearch cluster master CPU utilization above ${local.thresholds["MasterCPUUtilizationThreshold"]} over last ${var.alarm_master_cpu_utilization_too_high_periods * var.alarm_master_cpu_utilization_too_high_period / 60} minute(s) too high"
232+
alarm_description = "Average elasticsearch cluster master CPU utilization above ${local.thresholds["MasterCPUUtilizationThreshold"]} over last ${floor(var.alarm_master_cpu_utilization_too_high_periods * var.alarm_master_cpu_utilization_too_high_period / 60)} minute(s) too high"
233233
alarm_actions = [local.aws_sns_topic_arn]
234234
ok_actions = [local.aws_sns_topic_arn]
235235
tags = var.tags
@@ -251,7 +251,7 @@ resource "aws_cloudwatch_metric_alarm" "master_jvm_memory_pressure_too_high" {
251251
period = var.alarm_master_jvm_memory_pressure_too_high_period
252252
statistic = "Maximum"
253253
threshold = local.thresholds["MasterJVMMemoryPressureThreshold"]
254-
alarm_description = "Elasticsearch JVM memory pressure is over ${local.thresholds["MasterJVMMemoryPressureThreshold"]} over the last ${var.alarm_master_jvm_memory_pressure_too_high_periods * var.alarm_master_jvm_memory_pressure_too_high_period / 60} minute(s)"
254+
alarm_description = "Elasticsearch JVM memory pressure is over ${local.thresholds["MasterJVMMemoryPressureThreshold"]} over the last ${floor(var.alarm_master_jvm_memory_pressure_too_high_periods * var.alarm_master_jvm_memory_pressure_too_high_period / 60)} minute(s)"
255255
alarm_actions = [local.aws_sns_topic_arn]
256256
ok_actions = [local.aws_sns_topic_arn]
257257
tags = var.tags
@@ -273,7 +273,7 @@ resource "aws_cloudwatch_metric_alarm" "kms_key_error" {
273273
period = var.alarm_kms_period
274274
statistic = "Maximum"
275275
threshold = "1"
276-
alarm_description = "Elasticsearch KMS Key Error failed over last ${var.alarm_kms_periods * var.alarm_kms_period / 60} minute(s)"
276+
alarm_description = "Elasticsearch KMS Key Error failed over last ${floor(var.alarm_kms_periods * var.alarm_kms_period / 60)} minute(s)"
277277
alarm_actions = [local.aws_sns_topic_arn]
278278
ok_actions = [local.aws_sns_topic_arn]
279279
treat_missing_data = "ignore"
@@ -296,7 +296,7 @@ resource "aws_cloudwatch_metric_alarm" "kms_key_inaccessible" {
296296
period = var.alarm_kms_period
297297
statistic = "Maximum"
298298
threshold = "1"
299-
alarm_description = "Elasticsearch KMS Key Inaccessible failed over last ${var.alarm_kms_periods * var.alarm_kms_period / 60} minute(s)"
299+
alarm_description = "Elasticsearch KMS Key Inaccessible failed over last ${floor(var.alarm_kms_periods * var.alarm_kms_period / 60)} minute(s)"
300300
alarm_actions = [local.aws_sns_topic_arn]
301301
ok_actions = [local.aws_sns_topic_arn]
302302
treat_missing_data = "ignore"

0 commit comments

Comments
 (0)