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..64b0c53 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 = "Index slow logs ARN" + default = "" +} + +variable "search_slow_log_group_arn" { + description = "Search slow logs ARN" + default = "" +} + +variable "es_application_log_group_arn" { + description = "Error logs ARN" + default = "" +} + +variable "audit_log_group_arn" { + description = "Audit logs ARN" + 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