Skip to content

Commit 1ad14d5

Browse files
feat: cloudwatch alarms ok and insufficient_data state actions (#56)
1 parent 40e185e commit 1ad14d5

File tree

3 files changed

+75
-25
lines changed

3 files changed

+75
-25
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
| Name | Description | Type | Default | Required |
4242
|------|-------------|------|---------|:--------:|
4343
| <a name="input_access_policies"></a> [access\_policies](#input\_access\_policies) | IAM policy document specifying the access policies for the domain | `string` | `""` | no |
44-
| <a name="input_admin_identifiers"></a> [admin\_identifiers](#input\_admin\_identifiers) | Admin Identifiers to be allowed in the Access Policy of Opensearch Cluster | `list(string)` | <pre>[<br> "*"<br>]</pre> | no |
44+
| <a name="input_admin_identifiers"></a> [admin\_identifiers](#input\_admin\_identifiers) | Admin Identifiers to be allowed in the Access Policy of Opensearch Cluster | `list(string)` | <pre>[<br/> "*"<br/>]</pre> | no |
4545
| <a name="input_advanced_options"></a> [advanced\_options](#input\_advanced\_options) | Note that the values for these configuration options must be strings (wrapped in quotes) or they may be wrong and cause a perpetual diff, causing Terraform to want to recreate your OpenSearch domain on every apply. | `map(string)` | `{}` | no |
4646
| <a name="input_advanced_security_options_enabled"></a> [advanced\_security\_options\_enabled](#input\_advanced\_security\_options\_enabled) | Whether advanced security is enabled | `bool` | `false` | no |
4747
| <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)` | `[]` | no |
@@ -75,8 +75,9 @@
7575
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Specify the engine version for the Amazon OpenSearch Service domain | `string` | `"OpenSearch_1.3"` | no |
7676
| <a name="input_instance_count"></a> [instance\_count](#input\_instance\_count) | The number of dedicated hot nodes in the cluster. | `number` | `3` | no |
7777
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of EC2 instances to run for each hot node. A list of available instance types can you find at https://aws.amazon.com/en/opensearch-service/pricing/#On-Demand_instance_pricing | `string` | `"t3.small.search"` | no |
78+
| <a name="input_insufficient_data_actions"></a> [insufficient\_data\_actions](#input\_insufficient\_data\_actions) | The list of actions to execute when this alarm transitions into an INSUFFICIENT\_DATA state from any other state | `list(string)` | `[]` | no |
7879
| <a name="input_internal_user_database_enabled"></a> [internal\_user\_database\_enabled](#input\_internal\_user\_database\_enabled) | Whether the internal user database is enabled | `bool` | `false` | no |
79-
| <a name="input_log_publishing_options"></a> [log\_publishing\_options](#input\_log\_publishing\_options) | Configuration block for publishing slow and application logs to CloudWatch Logs. | <pre>map(object({<br> enabled = optional(bool, true)<br> cloudwatch_log_group_arn = optional(string, "")<br> }))</pre> | <pre>{<br> "audit_logs": {<br> "enabled": false<br> },<br> "index_slow_logs": {<br> "enabled": true<br> }<br>}</pre> | no |
80+
| <a name="input_log_publishing_options"></a> [log\_publishing\_options](#input\_log\_publishing\_options) | Configuration block for publishing slow and application logs to CloudWatch Logs. | <pre>map(object({<br/> enabled = optional(bool, true)<br/> cloudwatch_log_group_arn = optional(string, "")<br/> }))</pre> | <pre>{<br/> "audit_logs": {<br/> "enabled": false<br/> },<br/> "index_slow_logs": {<br/> "enabled": true<br/> }<br/>}</pre> | no |
8081
| <a name="input_maintenance_schedule"></a> [maintenance\_schedule](#input\_maintenance\_schedule) | configuration for auto tune maintenance schedule | `map(any)` | `{}` | no |
8182
| <a name="input_master_instance_count"></a> [master\_instance\_count](#input\_master\_instance\_count) | The number of dedicated master nodes in the cluster. | `number` | `3` | no |
8283
| <a name="input_master_instance_enabled"></a> [master\_instance\_enabled](#input\_master\_instance\_enabled) | Indicates whether dedicated master nodes are enabled for the cluster. | `bool` | `true` | no |
@@ -85,7 +86,8 @@
8586
| <a name="input_master_user_name"></a> [master\_user\_name](#input\_master\_user\_name) | Main user's username, which is stored in the Amazon OpenSearch Service domain's internal database | `string` | `""` | no |
8687
| <a name="input_master_user_password"></a> [master\_user\_password](#input\_master\_user\_password) | Main user's password, which is stored in the Amazon OpenSearch Service domain's internal database | `string` | `""` | no |
8788
| <a name="input_node_to_node_encryption_enabled"></a> [node\_to\_node\_encryption\_enabled](#input\_node\_to\_node\_encryption\_enabled) | Enable node-to-node encryption. | `bool` | `true` | no |
88-
| <a name="input_off_peak_window_options"></a> [off\_peak\_window\_options](#input\_off\_peak\_window\_options) | Configuration for off peak window | `map(any)` | <pre>{<br> "hours": 14,<br> "minutes": 0<br>}</pre> | no |
89+
| <a name="input_off_peak_window_options"></a> [off\_peak\_window\_options](#input\_off\_peak\_window\_options) | Configuration for off peak window | `map(any)` | <pre>{<br/> "hours": 14,<br/> "minutes": 0<br/>}</pre> | no |
90+
| <a name="input_ok_actions"></a> [ok\_actions](#input\_ok\_actions) | The list of actions to execute when this alarm transitions into an OK state from any other state | `list(string)` | `[]` | no |
8991
| <a name="input_rollback_on_disable"></a> [rollback\_on\_disable](#input\_rollback\_on\_disable) | whether to roll back auto tune if auto tune is disabled | `string` | `"NO_ROLLBACK"` | no |
9092
| <a name="input_saml_enabled"></a> [saml\_enabled](#input\_saml\_enabled) | Whether SAML authentication is enabled | `bool` | `false` | no |
9193
| <a name="input_saml_entity_id"></a> [saml\_entity\_id](#input\_saml\_entity\_id) | The unique Entity ID of the application in SAML Identity Provider. | `string` | `""` | no |

alarms.tf

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ locals {
2020
dimensions = {
2121
DomainName = aws_opensearch_domain.this.domain_name
2222
}
23-
alarm_actions = var.alarm_actions
23+
alarm_actions = var.alarm_actions
24+
ok_actions = var.ok_actions
25+
insufficient_data_actions = var.insufficient_data_actions
2426
}
2527

2628
cluster_status_yellow = {
@@ -40,7 +42,9 @@ locals {
4042
dimensions = {
4143
DomainName = aws_opensearch_domain.this.domain_name
4244
}
43-
alarm_actions = var.alarm_actions
45+
alarm_actions = var.alarm_actions
46+
ok_actions = var.ok_actions
47+
insufficient_data_actions = var.insufficient_data_actions
4448
}
4549

4650
cluster_writes_blocked = {
@@ -60,7 +64,9 @@ locals {
6064
dimensions = {
6165
DomainName = aws_opensearch_domain.this.domain_name
6266
}
63-
alarm_actions = var.alarm_actions
67+
alarm_actions = var.alarm_actions
68+
ok_actions = var.ok_actions
69+
insufficient_data_actions = var.insufficient_data_actions
6470
}
6571

6672
unreachable_nodes = {
@@ -80,7 +86,9 @@ locals {
8086
dimensions = {
8187
DomainName = aws_opensearch_domain.this.domain_name
8288
}
83-
alarm_actions = var.alarm_actions
89+
alarm_actions = var.alarm_actions
90+
ok_actions = var.ok_actions
91+
insufficient_data_actions = var.insufficient_data_actions
8492
}
8593
# /cluster status
8694

@@ -103,7 +111,9 @@ locals {
103111
dimensions = {
104112
DomainName = aws_opensearch_domain.this.domain_name
105113
}
106-
alarm_actions = var.alarm_actions
114+
alarm_actions = var.alarm_actions
115+
ok_actions = var.ok_actions
116+
insufficient_data_actions = var.insufficient_data_actions
107117
}
108118

109119
master_high_cpu_utilization = {
@@ -124,7 +134,9 @@ locals {
124134
dimensions = {
125135
DomainName = aws_opensearch_domain.this.domain_name
126136
}
127-
alarm_actions = var.alarm_actions
137+
alarm_actions = var.alarm_actions
138+
ok_actions = var.ok_actions
139+
insufficient_data_actions = var.insufficient_data_actions
128140
}
129141

130142
warm_high_cpu_utilization = {
@@ -146,7 +158,9 @@ locals {
146158
dimensions = {
147159
DomainName = aws_opensearch_domain.this.domain_name
148160
}
149-
alarm_actions = var.alarm_actions
161+
alarm_actions = var.alarm_actions
162+
ok_actions = var.ok_actions
163+
insufficient_data_actions = var.insufficient_data_actions
150164
}
151165
# /cpuutilization
152166

@@ -169,7 +183,9 @@ locals {
169183
dimensions = {
170184
DomainName = aws_opensearch_domain.this.domain_name
171185
}
172-
alarm_actions = var.alarm_actions
186+
alarm_actions = var.alarm_actions
187+
ok_actions = var.ok_actions
188+
insufficient_data_actions = var.insufficient_data_actions
173189
}
174190

175191
data_high_oldjvm_pressure = {
@@ -190,7 +206,9 @@ locals {
190206
dimensions = {
191207
DomainName = aws_opensearch_domain.this.domain_name
192208
}
193-
alarm_actions = var.alarm_actions
209+
alarm_actions = var.alarm_actions
210+
ok_actions = var.ok_actions
211+
insufficient_data_actions = var.insufficient_data_actions
194212
}
195213

196214
master_high_jvm_pressure = {
@@ -211,7 +229,9 @@ locals {
211229
dimensions = {
212230
DomainName = aws_opensearch_domain.this.domain_name
213231
}
214-
alarm_actions = var.alarm_actions
232+
alarm_actions = var.alarm_actions
233+
ok_actions = var.ok_actions
234+
insufficient_data_actions = var.insufficient_data_actions
215235
}
216236

217237
master_high_oldjvm_pressure = {
@@ -232,7 +252,9 @@ locals {
232252
dimensions = {
233253
DomainName = aws_opensearch_domain.this.domain_name
234254
}
235-
alarm_actions = var.alarm_actions
255+
alarm_actions = var.alarm_actions
256+
ok_actions = var.ok_actions
257+
insufficient_data_actions = var.insufficient_data_actions
236258
}
237259
# /jvmpressure
238260

@@ -256,7 +278,9 @@ locals {
256278
dimensions = {
257279
DomainName = aws_opensearch_domain.this.domain_name
258280
}
259-
alarm_actions = var.alarm_actions
281+
alarm_actions = var.alarm_actions
282+
ok_actions = var.ok_actions
283+
insufficient_data_actions = var.insufficient_data_actions
260284
}
261285

262286
aos_key_inaccessible = {
@@ -278,7 +302,9 @@ locals {
278302
dimensions = {
279303
DomainName = aws_opensearch_domain.this.domain_name
280304
}
281-
alarm_actions = var.alarm_actions
305+
alarm_actions = var.alarm_actions
306+
ok_actions = var.ok_actions
307+
insufficient_data_actions = var.insufficient_data_actions
282308
}
283309

284310
# 5xx errors
@@ -299,7 +325,9 @@ locals {
299325
dimensions = {
300326
DomainName = aws_opensearch_domain.this.domain_name
301327
}
302-
alarm_actions = var.alarm_actions
328+
alarm_actions = var.alarm_actions
329+
ok_actions = var.ok_actions
330+
insufficient_data_actions = var.insufficient_data_actions
303331
}
304332

305333
# threadpool
@@ -320,7 +348,9 @@ locals {
320348
dimensions = {
321349
DomainName = aws_opensearch_domain.this.domain_name
322350
}
323-
alarm_actions = var.alarm_actions
351+
alarm_actions = var.alarm_actions
352+
ok_actions = var.ok_actions
353+
insufficient_data_actions = var.insufficient_data_actions
324354
}
325355

326356
threadpool_high_search_avg = {
@@ -340,7 +370,9 @@ locals {
340370
dimensions = {
341371
DomainName = aws_opensearch_domain.this.domain_name
342372
}
343-
alarm_actions = var.alarm_actions
373+
alarm_actions = var.alarm_actions
374+
ok_actions = var.ok_actions
375+
insufficient_data_actions = var.insufficient_data_actions
344376
}
345377

346378
threadpool_high_search_max = {
@@ -360,7 +392,9 @@ locals {
360392
dimensions = {
361393
DomainName = aws_opensearch_domain.this.domain_name
362394
}
363-
alarm_actions = var.alarm_actions
395+
alarm_actions = var.alarm_actions
396+
ok_actions = var.ok_actions
397+
insufficient_data_actions = var.insufficient_data_actions
364398
}
365399

366400
# Migrations
@@ -382,7 +416,9 @@ locals {
382416
dimensions = {
383417
DomainName = aws_opensearch_domain.this.domain_name
384418
}
385-
alarm_actions = var.alarm_actions
419+
alarm_actions = var.alarm_actions
420+
ok_actions = var.ok_actions
421+
insufficient_data_actions = var.insufficient_data_actions
386422
}
387423
}
388424

variables.tf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,28 @@ variable "cloudwatch_log_group_retention_days" {
413413
############
414414
## Alerts ##
415415
############
416+
variable "create_alarms" {
417+
description = "Whether to create default set of alarms"
418+
type = bool
419+
default = true
420+
}
421+
416422
variable "alarm_actions" {
417423
description = "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)"
418424
type = list(string)
419425
default = []
420426
}
421427

422-
variable "create_alarms" {
423-
description = "Whether to create default set of alarms"
424-
type = bool
425-
default = true
428+
variable "ok_actions" {
429+
description = "The list of actions to execute when this alarm transitions into an OK state from any other state"
430+
type = list(string)
431+
default = []
432+
}
433+
434+
variable "insufficient_data_actions" {
435+
description = "The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state"
436+
type = list(string)
437+
default = []
426438
}
427439

428440
variable "alarm_overrides" {

0 commit comments

Comments
 (0)