-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
70 lines (61 loc) · 1.71 KB
/
main.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
/**
* Module usage:
*
* module "foo" {
* source = "github.com/grey-systems/terraform-elasticsearch.git?ref=master"
* name = "${var.domain_name}"
* environment = "${var.environment}"
* route53_zone_id = "${var.route53_zone_id}"
* ips_allowed = ["${var.your_ips_allowed_to_access_el}"]
* }
*
*/
resource "aws_elasticsearch_domain" "es" {
domain_name = "${var.environment}-${var.name}"
elasticsearch_version = "${var.es_version}"
advanced_options {
"rest.action.multi.allow_explicit_index" = "true"
}
# Temporal workaround to avoid repeated modifyings over this resource
lifecycle {
ignore_changes = ["access_policies"]
}
access_policies = <<CONFIG
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "es:*",
"Principal": "*",
"Effect": "Allow",
"Condition": {
"IpAddress": {"aws:SourceIp": ["${var.hq_default_ip}",${join(",",formatlist("\"%s/32\"",var.ips_allowed))}]}
}
}
]
}
CONFIG
ebs_options {
ebs_enabled = true
volume_type = "gp2"
volume_size = "${var.instance_ebs_size}"
}
cluster_config {
instance_type = "${var.instance_type}"
instance_count = "${var.number_instances}"
zone_awareness_enabled = "${var.zone_awareness_enabled}"
}
snapshot_options {
automated_snapshot_start_hour = "${var.automated_snapshot_start_hour}"
}
tags {
Domain = "${var.name}-domain"
}
}
resource "aws_route53_record" "dns" {
name = "${var.name}"
records = ["${aws_elasticsearch_domain.es.endpoint}"]
zone_id = "${var.route53_zone_id}"
ttl = "300"
type = "CNAME"
}