Skip to content

Commit 208a624

Browse files
fix: option to disable index slow logs
1 parent cda5a62 commit 208a624

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Opensearch
22

3-
<!-- BEGIN_TF_DOCS -->
43
## Requirements
54

65
| Name | Version |
@@ -75,7 +74,7 @@ No modules.
7574
| <a name="input_instance_count"></a> [instance\_count](#input\_instance\_count) | The number of dedicated hot nodes in the cluster. | `number` | `3` | no |
7675
| <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 |
7776
| <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 |
78-
| <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> | `{}` | no |
77+
| <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 |
7978
| <a name="input_maintenance_schedule"></a> [maintenance\_schedule](#input\_maintenance\_schedule) | configuration for auto tune maintenance schedule | `map(any)` | `{}` | no |
8079
| <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 |
8180
| <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 |
@@ -120,4 +119,3 @@ No modules.
120119
| <a name="output_vpc_endpoint_dns_names"></a> [vpc\_endpoint\_dns\_names](#output\_vpc\_endpoint\_dns\_names) | VPC endpoint DNS names |
121120
| <a name="output_vpc_endpoint_endpoint"></a> [vpc\_endpoint\_endpoint](#output\_vpc\_endpoint\_endpoint) | The connection endpoint ID for connecting to the domain |
122121
| <a name="output_vpc_endpoint_id"></a> [vpc\_endpoint\_id](#output\_vpc\_endpoint\_id) | The unique identifier of the endpoint |
123-
<!-- END_TF_DOCS -->

cloudwatch.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ locals {
55
resource "aws_cloudwatch_log_group" "aos" {
66
#checkov:skip=CKV_AWS_158:rely on aws default encryption
77
#checkov:skip=CKV_AWS_338:Ensure CloudWatch log groups retains logs for at least 1 year
8-
for_each = { for k, v in local.log_publishing_options : k => v if v.enabled }
8+
for_each = { for k, v in var.log_publishing_options : k => v if v.enabled && v.cloudwatch_log_group_arn == "" }
99

1010
name = "${local.log_prefix}/${each.key}"
1111
retention_in_days = var.cloudwatch_log_group_retention_days

examples/opensearch/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ module "opensearch" {
5757
encrypt_at_rest_enabled = true
5858
encrypt_kms_key_id = aws_kms_key.objects.id
5959

60+
log_publishing_options = {
61+
audit_logs = {
62+
enabled = true
63+
}
64+
index_slow_logs = {
65+
enabled = false
66+
}
67+
}
68+
6069
tags = {
6170
Domain = "TestDomain"
6271
Name = var.domain_name

locals.tf

Lines changed: 0 additions & 11 deletions
This file was deleted.

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ resource "aws_opensearch_domain" "this" {
9191
}
9292

9393
dynamic "log_publishing_options" {
94-
for_each = { for k, v in local.log_publishing_options : k => v if v.enabled }
94+
for_each = { for k, v in var.log_publishing_options : k => v if v.enabled }
9595
content {
9696
log_type = upper(log_publishing_options.key)
9797
enabled = log_publishing_options.value.enabled

variables.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,15 @@ variable "log_publishing_options" {
369369
enabled = optional(bool, true)
370370
cloudwatch_log_group_arn = optional(string, "")
371371
}))
372-
default = {}
372+
373+
default = {
374+
audit_logs = {
375+
enabled = false
376+
}
377+
index_slow_logs = {
378+
enabled = true
379+
}
380+
}
373381
}
374382

375383
variable "cloudwatch_log_group_retention_days" {

0 commit comments

Comments
 (0)