diff --git a/modules/metric-alarms-by-multiple-dimensions/README.md b/modules/metric-alarms-by-multiple-dimensions/README.md index 0156411..99f8b2d 100644 --- a/modules/metric-alarms-by-multiple-dimensions/README.md +++ b/modules/metric-alarms-by-multiple-dimensions/README.md @@ -32,6 +32,7 @@ No modules. | [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 | | [alarm\_description](#input\_alarm\_description) | The description for the alarm. | `string` | `null` | no | | [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 | +| [alarm\_name\_delimiter](#input\_alarm\_name\_delimiter) | Delimiter between alarm name and dimension key. Use dash or underscore for pretty alert names. | `string` | `""` | no | | [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 | | [create\_metric\_alarm](#input\_create\_metric\_alarm) | Whether to create the Cloudwatch metric alarm | `bool` | `true` | no | | [datapoints\_to\_alarm](#input\_datapoints\_to\_alarm) | The number of datapoints that must be breaching to trigger the alarm. | `number` | `null` | no | diff --git a/modules/metric-alarms-by-multiple-dimensions/main.tf b/modules/metric-alarms-by-multiple-dimensions/main.tf index 8213034..d46b3a5 100644 --- a/modules/metric-alarms-by-multiple-dimensions/main.tf +++ b/modules/metric-alarms-by-multiple-dimensions/main.tf @@ -1,7 +1,7 @@ resource "aws_cloudwatch_metric_alarm" "this" { for_each = { for k, v in var.dimensions : k => v if var.create_metric_alarm } - alarm_name = format("%s%s", var.alarm_name, each.key) + alarm_name = format("%s%s%s", var.alarm_name, var.alarm_name_delimiter, each.key) alarm_description = var.alarm_description actions_enabled = var.actions_enabled diff --git a/modules/metric-alarms-by-multiple-dimensions/variables.tf b/modules/metric-alarms-by-multiple-dimensions/variables.tf index f038797..b818a2a 100644 --- a/modules/metric-alarms-by-multiple-dimensions/variables.tf +++ b/modules/metric-alarms-by-multiple-dimensions/variables.tf @@ -9,6 +9,12 @@ variable "alarm_name" { type = string } +variable "alarm_name_delimiter" { + description = "Delimiter between alarm name and dimension key. Use dash or underscore for pretty alert names." + type = string + default = "" +} + variable "alarm_description" { description = "The description for the alarm." type = string diff --git a/wrappers/metric-alarms-by-multiple-dimensions/main.tf b/wrappers/metric-alarms-by-multiple-dimensions/main.tf index c064f60..27a81e9 100644 --- a/wrappers/metric-alarms-by-multiple-dimensions/main.tf +++ b/wrappers/metric-alarms-by-multiple-dimensions/main.tf @@ -5,6 +5,7 @@ module "wrapper" { create_metric_alarm = try(each.value.create_metric_alarm, var.defaults.create_metric_alarm, true) alarm_name = try(each.value.alarm_name, var.defaults.alarm_name) + alarm_name_delimiter = try(each.value.alarm_name_delimiter, var.defaults.alarm_name_delimiter, "") alarm_description = try(each.value.alarm_description, var.defaults.alarm_description, null) comparison_operator = try(each.value.comparison_operator, var.defaults.comparison_operator) evaluation_periods = try(each.value.evaluation_periods, var.defaults.evaluation_periods)