Skip to content

Commit fdb39b7

Browse files
authored
feat: Add option to specify default ok no data actions (#44)
1 parent 9a51828 commit fdb39b7

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

examples/cis-alarms/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ No providers.
3030

3131
| Name | Source | Version |
3232
|------|--------|---------|
33+
| <a name="module_all_action_types"></a> [all\_action\_types](#module\_all\_action\_types) | ../../modules/cis-alarms | n/a |
3334
| <a name="module_all_cis_alarms"></a> [all\_cis\_alarms](#module\_all\_cis\_alarms) | ../../modules/cis-alarms | n/a |
3435
| <a name="module_aws_sns_topic"></a> [aws\_sns\_topic](#module\_aws\_sns\_topic) | ../fixtures/aws_sns_topic | n/a |
3536
| <a name="module_control_overrides"></a> [control\_overrides](#module\_control\_overrides) | ../../modules/cis-alarms | n/a |

examples/cis-alarms/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ module "control_overrides" {
5151
}
5252
}
5353
}
54+
55+
module "all_action_types" {
56+
source = "../../modules/cis-alarms"
57+
58+
log_group_name = module.log.cloudwatch_log_group_name
59+
alarm_actions = [module.aws_sns_topic.sns_topic_arn]
60+
ok_actions = [module.aws_sns_topic.sns_topic_arn]
61+
insufficient_data_actions = [module.aws_sns_topic.sns_topic_arn]
62+
}

modules/cis-alarms/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ No modules.
3939
| <a name="input_control_overrides"></a> [control\_overrides](#input\_control\_overrides) | A map of overrides to apply to each control | `any` | `{}` | no |
4040
| <a name="input_create"></a> [create](#input\_create) | Whether to create the Cloudwatch log metric filter and metric alarms | `bool` | `true` | no |
4141
| <a name="input_disabled_controls"></a> [disabled\_controls](#input\_disabled\_controls) | List of IDs of disabled CIS controls | `list(string)` | `[]` | no |
42+
| <a name="input_insufficient_data_actions"></a> [insufficient\_data\_actions](#input\_insufficient\_data\_actions) | List of ARNs to put as Cloudwatch insuficient data actions (eg, ARN of SNS topic) | `list(string)` | `[]` | no |
4243
| <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 |
4344
| <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 |
4445
| <a name="input_namespace"></a> [namespace](#input\_namespace) | The namespace where metric filter and metric alarm should be cleated | `string` | `"CISBenchmark"` | no |
46+
| <a name="input_ok_actions"></a> [ok\_actions](#input\_ok\_actions) | List of ARNs to put as Cloudwatch OK actions (eg, ARN of SNS topic) | `list(string)` | `[]` | no |
4547
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags to assign to all resources | `map(string)` | `{}` | no |
4648
| <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 |
4749

modules/cis-alarms/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ resource "aws_cloudwatch_metric_alarm" "this" {
113113

114114
actions_enabled = lookup(each.value, "actions_enabled", var.actions_enabled)
115115
alarm_actions = lookup(each.value, "alarm_actions", var.alarm_actions)
116-
ok_actions = lookup(each.value, "ok_actions", null)
117-
insufficient_data_actions = lookup(each.value, "insufficient_data_actions", null)
116+
ok_actions = lookup(each.value, "ok_actions", var.ok_actions)
117+
insufficient_data_actions = lookup(each.value, "insufficient_data_actions", var.insufficient_data_actions)
118118

119119
comparison_operator = lookup(each.value, "comparison_operator", "GreaterThanOrEqualToThreshold")
120120
evaluation_periods = lookup(each.value, "evaluation_periods", 1)

modules/cis-alarms/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,15 @@ variable "tags" {
5757
type = map(string)
5858
default = {}
5959
}
60+
61+
variable "ok_actions" {
62+
description = "List of ARNs to put as Cloudwatch OK actions (eg, ARN of SNS topic)"
63+
type = list(string)
64+
default = []
65+
}
66+
67+
variable "insufficient_data_actions" {
68+
description = "List of ARNs to put as Cloudwatch insuficient data actions (eg, ARN of SNS topic)"
69+
type = list(string)
70+
default = []
71+
}

0 commit comments

Comments
 (0)