Skip to content

Commit 2328d90

Browse files
authored
Merge pull request #21 from egarbi/Improves_testing_case
Improves/Update testing case
2 parents ccbd2c5 + 684febf commit 2328d90

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ AWS Elasticsearch Service Terraform Module
44
Usage:
55

66
```hcl
7+
data "aws_region" "current" {}
8+
9+
data "aws_caller_identity" "current" {}
10+
711
module "es-cluster" {
812
source = "git::https://github.com/egarbi/terraform-aws-es-cluster"
913
1014
name = "example"
1115
vpc_id = "vpc-xxxxx"
12-
subnet_ids = [ "subnet-one","subnet-two"]
16+
subnet_ids = [ "subnet-one" ]
1317
zone_id = "ZA863HSKDDD9"
1418
itype = "m4.large.elasticsearch"
1519
ingress_allow_cidr_blocks = [ "10.20.0.0/16", "10.22.0.0/16" ]
@@ -21,9 +25,7 @@ module "es-cluster" {
2125
"Action": "es:*",
2226
"Principal": "*",
2327
"Effect": "Allow",
24-
"Condition": {
25-
"IpAddress": {"aws:SourceIp": ["66.193.100.22/32"]}
26-
}
28+
"Resource": "arn:aws:es:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:domain/example/*"
2729
}
2830
]
2931
}

example/main.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@ data "aws_route53_zone" "selected" {
2121
name = "qndesign.studio"
2222
}
2323

24+
data "aws_region" "current" {}
25+
26+
data "aws_caller_identity" "current" {}
27+
2428
module "es-cluster" {
2529
source = "../"
2630

2731
name = "example"
2832
vpc_id = "${data.aws_vpc.default.id}"
29-
subnet_ids = "${tolist(data.aws_subnet_ids.default.ids)}"
33+
subnet_ids = [ "${data.aws_subnet.default.0.id}", "${data.aws_subnet.default.1.id}" ]
3034
zone_id = "${data.aws_route53_zone.selected.zone_id}"
3135
itype = "m4.large.elasticsearch"
32-
ingress_allow_cidr_blocks = "${tolist(data.aws_subnet.default.*.cidr_block)}"
36+
icount = 2
37+
zone_awareness = true
38+
ingress_allow_cidr_blocks = [ "${data.aws_vpc.default.cidr_block}" ]
3339
access_policies = <<CONFIG
3440
{
3541
"Version": "2012-10-17",
@@ -38,9 +44,7 @@ module "es-cluster" {
3844
"Action": "es:*",
3945
"Principal": "*",
4046
"Effect": "Allow",
41-
"Condition": {
42-
"IpAddress": {"aws:SourceIp": ["156.114.160.31/32"]}
43-
}
47+
"Resource": "arn:aws:es:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:domain/example/*"
4448
}
4549
]
4650
}

0 commit comments

Comments
 (0)