Skip to content

Commit

Permalink
Merge pull request #1 from chrkv/master-nodes-and-logs
Browse files Browse the repository at this point in the history
feat: introduce master nodes and logs configuration
  • Loading branch information
chrkv authored Nov 19, 2021
2 parents 900b298 + dc2cc40 commit a64cbe6
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 14 deletions.
28 changes: 27 additions & 1 deletion elasticsearch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,38 @@ 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
}

vpc_options {
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"
}
}
62 changes: 49 additions & 13 deletions varaibles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit a64cbe6

Please sign in to comment.