Skip to content

Commit 0959943

Browse files
authored
feat: Add option to define a delimiter for metric-alarms-by-multiple-dimensions (#66)
1 parent 6434bd3 commit 0959943

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

modules/metric-alarms-by-multiple-dimensions/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ No modules.
3232
| <a name="input_alarm_actions"></a> [alarm\_actions](#input\_alarm\_actions) | The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN). | `list(string)` | `null` | no |
3333
| <a name="input_alarm_description"></a> [alarm\_description](#input\_alarm\_description) | The description for the alarm. | `string` | `null` | no |
3434
| <a name="input_alarm_name"></a> [alarm\_name](#input\_alarm\_name) | The descriptive name for the alarm. This name must be unique within the user's AWS account. | `string` | n/a | yes |
35+
| <a name="input_alarm_name_delimiter"></a> [alarm\_name\_delimiter](#input\_alarm\_name\_delimiter) | Delimiter between alarm name and dimension key. Use dash or underscore for pretty alert names. | `string` | `""` | no |
3536
| <a name="input_comparison_operator"></a> [comparison\_operator](#input\_comparison\_operator) | The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold. | `string` | n/a | yes |
3637
| <a name="input_create_metric_alarm"></a> [create\_metric\_alarm](#input\_create\_metric\_alarm) | Whether to create the Cloudwatch metric alarm | `bool` | `true` | no |
3738
| <a name="input_datapoints_to_alarm"></a> [datapoints\_to\_alarm](#input\_datapoints\_to\_alarm) | The number of datapoints that must be breaching to trigger the alarm. | `number` | `null` | no |

modules/metric-alarms-by-multiple-dimensions/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "aws_cloudwatch_metric_alarm" "this" {
22
for_each = { for k, v in var.dimensions : k => v if var.create_metric_alarm }
33

4-
alarm_name = format("%s%s", var.alarm_name, each.key)
4+
alarm_name = format("%s%s%s", var.alarm_name, var.alarm_name_delimiter, each.key)
55
alarm_description = var.alarm_description
66
actions_enabled = var.actions_enabled
77

modules/metric-alarms-by-multiple-dimensions/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ variable "alarm_name" {
99
type = string
1010
}
1111

12+
variable "alarm_name_delimiter" {
13+
description = "Delimiter between alarm name and dimension key. Use dash or underscore for pretty alert names."
14+
type = string
15+
default = ""
16+
}
17+
1218
variable "alarm_description" {
1319
description = "The description for the alarm."
1420
type = string

wrappers/metric-alarms-by-multiple-dimensions/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module "wrapper" {
55

66
create_metric_alarm = try(each.value.create_metric_alarm, var.defaults.create_metric_alarm, true)
77
alarm_name = try(each.value.alarm_name, var.defaults.alarm_name)
8+
alarm_name_delimiter = try(each.value.alarm_name_delimiter, var.defaults.alarm_name_delimiter, "")
89
alarm_description = try(each.value.alarm_description, var.defaults.alarm_description, null)
910
comparison_operator = try(each.value.comparison_operator, var.defaults.comparison_operator)
1011
evaluation_periods = try(each.value.evaluation_periods, var.defaults.evaluation_periods)

0 commit comments

Comments
 (0)