Skip to content

Commit 9d5d1c4

Browse files
authored
feat: Added support for custom CIS alarm names (#29)
1 parent 4f41097 commit 9d5d1c4

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

modules/cis-alarms/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ No modules.
3939
| <a name="input_create"></a> [create](#input\_create) | Whether to create the Cloudwatch log metric filter and metric alarms | `bool` | `true` | no |
4040
| <a name="input_disabled_controls"></a> [disabled\_controls](#input\_disabled\_controls) | List of IDs of disabled CIS controls | `list(string)` | `[]` | no |
4141
| <a name="input_log_group_name"></a> [log\_group\_name](#input\_log\_group\_name) | The name of the log group to associate the metric filter with | `string` | `""` | no |
42+
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | A name prefix for the cloudwatch alarm (if use\_random\_name\_prefix is true, this will be ignored) | `string` | `""` | no |
4243
| <a name="input_namespace"></a> [namespace](#input\_namespace) | The namespace where metric filter and metric alarm should be cleated | `string` | `"CISBenchmark"` | no |
4344
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags to assign to all resources | `map(string)` | `{}` | no |
4445
| <a name="input_use_random_name_prefix"></a> [use\_random\_name\_prefix](#input\_use\_random\_name\_prefix) | Whether to prefix resource names with random prefix | `bool` | `false` | no |
@@ -49,4 +50,4 @@ No modules.
4950
|------|-------------|
5051
| <a name="output_cloudwatch_metric_alarm_arns"></a> [cloudwatch\_metric\_alarm\_arns](#output\_cloudwatch\_metric\_alarm\_arns) | List of ARNs of the Cloudwatch metric alarm |
5152
| <a name="output_cloudwatch_metric_alarm_ids"></a> [cloudwatch\_metric\_alarm\_ids](#output\_cloudwatch\_metric\_alarm\_ids) | List of IDs of the Cloudwatch metric alarm |
52-
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
53+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/cis-alarms/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ locals {
7878

7979
###############
8080

81-
prefix = var.use_random_name_prefix ? "${random_pet.this[0].id}-" : ""
81+
prefix = var.use_random_name_prefix ? "${random_pet.this[0].id}-" : var.name_prefix
8282
controls = { for k, v in local.all_controls : k => v if !contains(var.disabled_controls, k) }
8383
}
8484

modules/cis-alarms/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ variable "use_random_name_prefix" {
1010
default = false
1111
}
1212

13+
variable "name_prefix" {
14+
description = "A name prefix for the cloudwatch alarm (if use_random_name_prefix is true, this will be ignored)"
15+
type = string
16+
default = ""
17+
}
18+
1319
variable "disabled_controls" {
1420
description = "List of IDs of disabled CIS controls"
1521
type = list(string)

0 commit comments

Comments
 (0)