From 72159761677a8d2e571871cb71e1de13ca6dfdfe Mon Sep 17 00:00:00 2001 From: Ivan Chirkov Date: Thu, 14 Oct 2021 21:23:55 +0200 Subject: [PATCH 1/2] feat: introduce master nodes and logs configuration --- elasticsearch.tf | 28 +++++++++++++++++++++- varaibles.tf | 62 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 14 deletions(-) diff --git a/elasticsearch.tf b/elasticsearch.tf index d754931..1538c85 100644 --- a/elasticsearch.tf +++ b/elasticsearch.tf @@ -12,7 +12,9 @@ resource "aws_elasticsearch_domain" "default" { cluster_config { instance_count = local.node_amount instance_type = local.node_instance_type - dedicated_master_enabled = false + dedicated_master_count = local.dedicated_master_count + dedicated_master_type = local.dedicated_master_type + dedicated_master_enabled = local.dedicated_master_count == 0 ? false : true zone_awareness_enabled = local.multi_az } @@ -20,4 +22,28 @@ resource "aws_elasticsearch_domain" "default" { security_group_ids = [aws_security_group.elasticsearch.id] subnet_ids = local.subnets } + + log_publishing_options { + cloudwatch_log_group_arn = local.index_slow_log_group_arn + enabled = local.index_slow_log_group_arn == "" ? false : true + log_type = "INDEX_SLOW_LOGS" + } + + log_publishing_options { + cloudwatch_log_group_arn = local.search_slow_log_group_arn + enabled = local.search_slow_log_group_arn == "" ? false : true + log_type = "SEARCH_SLOW_LOGS" + } + + log_publishing_options { + cloudwatch_log_group_arn = local.es_application_log_group_arn + enabled = local.es_application_log_group_arn == "" ? false : true + log_type = "ES_APPLICATION_LOGS" + } + + log_publishing_options { + cloudwatch_log_group_arn = local.audit_log_group_arn + enabled = local.audit_log_group_arn == "" ? false : true + log_type = "AUDIT_LOGS" + } } diff --git a/varaibles.tf b/varaibles.tf index fe90cf9..399715d 100644 --- a/varaibles.tf +++ b/varaibles.tf @@ -16,6 +16,36 @@ variable "node_instance_type" { default = "t2.small.elasticsearch" } +variable "dedicated_master_type" { + description = "Instance type of dedicated master node." + default = "t3.small.elasticsearch" +} + +variable "dedicated_master_count" { + description = "Amount of dedicated master nodes." + default = "0" +} + +variable "index_slow_log_group_arn" { + description = "XXX" + default = "" +} + +variable "search_slow_log_group_arn" { + description = "XXX" + default = "" +} + +variable "es_application_log_group_arn" { + description = "XXX" + default = "" +} + +variable "audit_log_group_arn" { + description = "XXX" + default = "" +} + variable "node_disk_size" { description = "Disk size of cluster node." default = "10" @@ -64,17 +94,23 @@ data "aws_subnet" "default" { } locals { - project = var.project - vpc_id = data.aws_subnet.default.vpc_id - region = data.aws_region.current.name - account_id = data.aws_caller_identity.current.account_id - domain_name = var.name - domain_arn = "arn:aws:es:${local.region}:${local.account_id}:domain/${local.domain_name}" - version = var.elasticsearch_version - node_instance_type = var.node_instance_type - node_disk_size = var.node_disk_size - node_amount = var.node_amount - subnets = var.subnets - trusted_cidr_blocks = var.trusted_cidr_blocks - multi_az = var.multi_az + project = var.project + vpc_id = data.aws_subnet.default.vpc_id + region = data.aws_region.current.name + account_id = data.aws_caller_identity.current.account_id + domain_name = var.name + domain_arn = "arn:aws:es:${local.region}:${local.account_id}:domain/${local.domain_name}" + version = var.elasticsearch_version + node_instance_type = var.node_instance_type + dedicated_master_count = var.dedicated_master_count + dedicated_master_type = var.dedicated_master_type + index_slow_log_group_arn = var.index_slow_log_group_arn + search_slow_log_group_arn = var.search_slow_log_group_arn + es_application_log_group_arn = var.es_application_log_group_arn + audit_log_group_arn = var.audit_log_group_arn + node_disk_size = var.node_disk_size + node_amount = var.node_amount + subnets = var.subnets + trusted_cidr_blocks = var.trusted_cidr_blocks + multi_az = var.multi_az } \ No newline at end of file From dc2cc40c1a069b9643f97a9550a6846fe3038408 Mon Sep 17 00:00:00 2001 From: Ivan Chirkov Date: Fri, 19 Nov 2021 14:24:46 +0100 Subject: [PATCH 2/2] fix: sensible descriptions for logs ARNs --- varaibles.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/varaibles.tf b/varaibles.tf index 399715d..64b0c53 100644 --- a/varaibles.tf +++ b/varaibles.tf @@ -27,22 +27,22 @@ variable "dedicated_master_count" { } variable "index_slow_log_group_arn" { - description = "XXX" + description = "Index slow logs ARN" default = "" } variable "search_slow_log_group_arn" { - description = "XXX" + description = "Search slow logs ARN" default = "" } variable "es_application_log_group_arn" { - description = "XXX" + description = "Error logs ARN" default = "" } variable "audit_log_group_arn" { - description = "XXX" + description = "Audit logs ARN" default = "" }