-
-
Notifications
You must be signed in to change notification settings - Fork 231
/
elasticsearch_domain.tf
146 lines (124 loc) · 5.13 KB
/
elasticsearch_domain.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#
# Elasticsearch Domain
#
resource "aws_elasticsearch_domain_policy" "default" {
count = local.elasticsearch_enabled && (length(var.iam_authorizing_role_arns) > 0 || length(var.iam_role_arns) > 0) ? 1 : 0
domain_name = module.this.id
access_policies = join("", data.aws_iam_policy_document.default[*].json)
}
resource "aws_elasticsearch_domain" "default" {
count = local.elasticsearch_enabled ? 1 : 0
domain_name = module.this.id
elasticsearch_version = var.elasticsearch_version
advanced_options = var.advanced_options
advanced_security_options {
enabled = var.advanced_security_options_enabled
internal_user_database_enabled = var.advanced_security_options_internal_user_database_enabled
master_user_options {
master_user_arn = var.advanced_security_options_master_user_arn
master_user_name = var.advanced_security_options_master_user_name
master_user_password = var.advanced_security_options_master_user_password
}
}
ebs_options {
ebs_enabled = var.ebs_volume_size > 0 ? true : false
volume_size = var.ebs_volume_size
volume_type = var.ebs_volume_type
iops = var.ebs_iops
throughput = var.ebs_throughput
}
encrypt_at_rest {
enabled = var.encrypt_at_rest_enabled
kms_key_id = var.encrypt_at_rest_kms_key_id
}
domain_endpoint_options {
enforce_https = var.domain_endpoint_options_enforce_https
tls_security_policy = var.domain_endpoint_options_tls_security_policy
custom_endpoint_enabled = var.custom_endpoint_enabled
custom_endpoint = var.custom_endpoint_enabled ? var.custom_endpoint : null
custom_endpoint_certificate_arn = var.custom_endpoint_enabled ? var.custom_endpoint_certificate_arn : null
}
cluster_config {
instance_count = var.instance_count
instance_type = var.instance_type
dedicated_master_enabled = var.dedicated_master_enabled
dedicated_master_count = var.dedicated_master_enabled ? var.dedicated_master_count : null
dedicated_master_type = var.dedicated_master_enabled ? var.dedicated_master_type : null
zone_awareness_enabled = var.zone_awareness_enabled
warm_enabled = var.warm_enabled
warm_count = var.warm_enabled ? var.warm_count : null
warm_type = var.warm_enabled ? var.warm_type : null
dynamic "zone_awareness_config" {
for_each = var.availability_zone_count > 1 && var.zone_awareness_enabled ? [true] : []
content {
availability_zone_count = var.availability_zone_count
}
}
dynamic "cold_storage_options" {
for_each = var.cold_storage_enabled ? [true] : []
content {
enabled = var.cold_storage_enabled
}
}
}
dynamic "auto_tune_options" {
for_each = var.auto_tune.enabled ? [true] : []
content {
desired_state = "ENABLED"
rollback_on_disable = var.auto_tune.rollback_on_disable
maintenance_schedule {
# Required until https://github.com/hashicorp/terraform-provider-aws/issues/22239 would be resolved
start_at = var.auto_tune.starting_time == null ? timeadd(timestamp(), "1h") : var.auto_tune.starting_time
duration {
value = var.auto_tune.duration
unit = "HOURS"
}
cron_expression_for_recurrence = var.auto_tune.cron_schedule
}
}
}
node_to_node_encryption {
enabled = var.node_to_node_encryption_enabled
}
dynamic "vpc_options" {
for_each = var.vpc_enabled ? [true] : []
content {
security_group_ids = var.create_security_group ? [join("", aws_security_group.default[*].id)] : var.security_groups
subnet_ids = var.subnet_ids
}
}
snapshot_options {
automated_snapshot_start_hour = var.automated_snapshot_start_hour
}
dynamic "cognito_options" {
for_each = var.cognito_authentication_enabled ? [true] : []
content {
enabled = true
user_pool_id = var.cognito_user_pool_id
identity_pool_id = var.cognito_identity_pool_id
role_arn = var.cognito_iam_role_arn
}
}
log_publishing_options {
enabled = var.log_publishing_index_enabled
log_type = "INDEX_SLOW_LOGS"
cloudwatch_log_group_arn = var.log_publishing_index_cloudwatch_log_group_arn
}
log_publishing_options {
enabled = var.log_publishing_search_enabled
log_type = "SEARCH_SLOW_LOGS"
cloudwatch_log_group_arn = var.log_publishing_search_cloudwatch_log_group_arn
}
log_publishing_options {
enabled = var.log_publishing_audit_enabled
log_type = "AUDIT_LOGS"
cloudwatch_log_group_arn = var.log_publishing_audit_cloudwatch_log_group_arn
}
log_publishing_options {
enabled = var.log_publishing_application_enabled
log_type = "ES_APPLICATION_LOGS"
cloudwatch_log_group_arn = var.log_publishing_application_cloudwatch_log_group_arn
}
tags = module.this.tags
depends_on = [aws_iam_service_linked_role.default]
}