-
Notifications
You must be signed in to change notification settings - Fork 7
/
amazon-opensearch.tf
91 lines (77 loc) · 2.01 KB
/
amazon-opensearch.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
variable "domain_name" {
type = string
default = "os4gophers"
}
variable "opensearch_username" {
type = string
default = "opensearch_user"
}
variable "opensearch_password" {
type = string
default = "W&lcome123"
sensitive = true
}
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
resource "aws_opensearch_domain" "opensearch" {
domain_name = var.domain_name
engine_version = "OpenSearch_2.13"
cluster_config {
dedicated_master_enabled = true
dedicated_master_type = "m6g.large.search"
dedicated_master_count = 3
instance_type = "r6g.large.search"
instance_count = 3
zone_awareness_enabled = true
zone_awareness_config {
availability_zone_count = 3
}
warm_enabled = true
warm_type = "ultrawarm1.large.search"
warm_count = 2
}
advanced_security_options {
enabled = true
anonymous_auth_enabled = false
internal_user_database_enabled = true
master_user_options {
master_user_name = var.opensearch_username
master_user_password = var.opensearch_password
}
}
domain_endpoint_options {
enforce_https = true
tls_security_policy = "Policy-Min-TLS-1-2-2019-07"
}
encrypt_at_rest {
enabled = true
}
ebs_options {
ebs_enabled = true
volume_size = 300
volume_type = "gp3"
throughput = 250
}
node_to_node_encryption {
enabled = true
}
access_policies = <<CONFIG
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "es:*",
"Principal": "*",
"Effect": "Allow",
"Resource": "arn:aws:es:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:domain/${var.domain_name}/*"
}
]
}
CONFIG
}
output "domain_endpoint" {
value = "https://${aws_opensearch_domain.opensearch.endpoint}"
}
output "opensearch_dashboards" {
value = "https://${aws_opensearch_domain.opensearch.dashboard_endpoint}"
}