Skip to content

Commit bf6e9ba

Browse files
authored
Merge pull request #7 from angelbarrera92/master
[Feature Request] access_policies variable #5 - master
2 parents 128b732 + c9a9c27 commit bf6e9ba

2 files changed

Lines changed: 40 additions & 15 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,21 @@ module "es-cluster" {
1313
zone_id = "ZA863HSKDDD9"
1414
itype = "m4.large.elasticsearch"
1515
ingress_allow_cidr_blocks = [ "10.20.0.0/16", "10.22.0.0/16" ]
16+
access_policies = <<CONFIG
17+
{
18+
"Version": "2012-10-17",
19+
"Statement": [
20+
{
21+
"Action": "es:*",
22+
"Principal": "*",
23+
"Effect": "Allow",
24+
"Condition": {
25+
"IpAddress": {"aws:SourceIp": ["66.193.100.22/32"]}
26+
}
27+
}
28+
]
29+
}
30+
CONFIG
31+
1632
}
1733
```

main.tf

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Required
22
variable "name" {}
3+
34
variable "vpc_id" {}
5+
46
variable "subnet_ids" {
57
type = "list"
68
}
7-
variable "zone_id" {}
89

10+
variable "zone_id" {}
911

1012
// Optional
1113
variable "elasticsearch_version" {
@@ -47,6 +49,7 @@ variable "ingress_allow_cidr_blocks" {
4749
variable "rest_action_multi_allow_explicit_index" {
4850
default = "true"
4951
}
52+
5053
variable "indices_fielddata_cache_size" {
5154
default = ""
5255
}
@@ -63,16 +66,20 @@ variable "volume_size" {
6366
default = "35"
6467
}
6568

69+
variable "access_policies" {
70+
description = "IAM policy document specifying the access policies for the domain"
71+
default = ""
72+
}
6673

6774
resource "aws_security_group" "elasticsearch" {
6875
name = "${var.name}"
6976
description = "Security Group to allow traffic to ElasticSearch"
7077

71-
ingress {
72-
from_port = 443
73-
to_port = 443
74-
protocol = "tcp"
75-
cidr_blocks = ["${var.ingress_allow_cidr_blocks}"]
78+
ingress {
79+
from_port = 443
80+
to_port = 443
81+
protocol = "tcp"
82+
cidr_blocks = ["${var.ingress_allow_cidr_blocks}"]
7683
}
7784

7885
ingress {
@@ -97,23 +104,25 @@ resource "aws_elasticsearch_domain" "es" {
97104
elasticsearch_version = "${var.elasticsearch_version}"
98105

99106
cluster_config {
100-
instance_type = "${var.itype}"
101-
instance_count = "${var.icount}"
107+
instance_type = "${var.itype}"
108+
instance_count = "${var.icount}"
102109
dedicated_master_enabled = "${var.dedicated_master}"
103-
dedicated_master_type = "${var.mtype}"
104-
dedicated_master_count = "${var.mcount}"
105-
zone_awareness_enabled = "${var.zone_awareness}"
110+
dedicated_master_type = "${var.mtype}"
111+
dedicated_master_count = "${var.mcount}"
112+
zone_awareness_enabled = "${var.zone_awareness}"
106113
}
107114

115+
access_policies = "${var.access_policies}"
116+
108117
vpc_options {
109-
security_group_ids = [ "${aws_security_group.elasticsearch.id}" ]
110-
subnet_ids = [ "${var.subnet_ids}" ]
118+
security_group_ids = ["${aws_security_group.elasticsearch.id}"]
119+
subnet_ids = ["${var.subnet_ids}"]
111120
}
112121

113122
advanced_options {
114123
"rest.action.multi.allow_explicit_index" = "${var.rest_action_multi_allow_explicit_index}"
115-
"indices.fielddata.cache.size" = "${var.indices_fielddata_cache_size}"
116-
"indices.query.bool.max_clause_count" = "${var.indices_query_bool_max_clause_count}"
124+
"indices.fielddata.cache.size" = "${var.indices_fielddata_cache_size}"
125+
"indices.query.bool.max_clause_count" = "${var.indices_query_bool_max_clause_count}"
117126
}
118127

119128
ebs_options {

0 commit comments

Comments
 (0)