File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,33 +2,47 @@ resource "aws_security_group" "elasticsearch" {
22 name = " ${ var . name } "
33 description = " Security Group to allow traffic to ElasticSearch"
44
5- ingress {
6- from_port = 443
7- to_port = 443
8- protocol = " tcp"
9- cidr_blocks = [" ${ var . ingress_allow_cidr_blocks } " ]
10- }
5+ vpc_id = " ${ var . vpc_id } "
6+ }
117
12- ingress {
13- from_port = 443
14- to_port = 443
15- protocol = " tcp"
16- security_groups = [" ${ var . ingress_allow_security_groups } " ]
17- }
8+ resource "aws_security_group_rule" "secure_cidrs" {
9+ count = " ${ length (var. ingress_allow_cidr_blocks ) > 0 ? 1 : 0 } "
1810
19- egress {
20- from_port = 0
21- to_port = 0
22- protocol = " -1"
23- cidr_blocks = [" 0.0.0.0/0" ]
24- }
11+ type = " ingress"
12+ from_port = 443
13+ to_port = 443
14+ protocol = " TCP"
15+ cidr_blocks = [" ${ var . ingress_allow_cidr_blocks } " ]
2516
26- vpc_id = " ${ var . vpc_id } "
17+ security_group_id = " ${ aws_security_group . elasticsearch . id } "
18+ }
19+
20+ resource "aws_security_group_rule" "secure_sgs" {
21+ count = " ${ length (var. ingress_allow_security_groups )} "
22+
23+ type = " ingress"
24+ from_port = 443
25+ to_port = 443
26+ protocol = " tcp"
27+ source_security_group_id = " ${ element (var. ingress_allow_security_groups , count. index )} "
28+
29+ security_group_id = " ${ aws_security_group . elasticsearch . id } "
30+ }
31+
32+ resource "aws_security_group_rule" "egress_all" {
33+ type = " egress"
34+ from_port = 0
35+ to_port = 0
36+ protocol = " -1"
37+ cidr_blocks = [" 0.0.0.0/0" ]
38+
39+ security_group_id = " ${ aws_security_group . elasticsearch . id } "
2740}
2841
2942resource "aws_elasticsearch_domain" "es" {
3043 domain_name = " ${ var . name } "
3144 elasticsearch_version = " ${ var . elasticsearch_version } "
45+
3246 encrypt_at_rest {
3347 enabled = " ${ var . encryption_enabled } "
3448 kms_key_id = " ${ var . encryption_kms_key_id } "
Original file line number Diff line number Diff line change @@ -3,15 +3,15 @@ output "es_endpoint" {
33}
44
55output "es_arn" {
6- value = " ${ aws_elasticsearch_domain . es . arn } "
6+ value = " ${ aws_elasticsearch_domain . es . arn } "
77}
88
99output "es_domain_id" {
10- value = " ${ aws_elasticsearch_domain . es . domain_id } "
10+ value = " ${ aws_elasticsearch_domain . es . domain_id } "
1111}
1212
1313output "es_kibana_endpoint" {
14- value = " ${ aws_elasticsearch_domain . es . kibana_endpoint } "
14+ value = " ${ aws_elasticsearch_domain . es . kibana_endpoint } "
1515}
1616
1717output "es_availability_zones_ids" {
@@ -21,3 +21,7 @@ output "es_availability_zones_ids" {
2121output "es_vpc_ids" {
2222 value = " ${ aws_elasticsearch_domain . es . vpc_options . 0 . vpc_id } "
2323}
24+
25+ output "es_sg" {
26+ value = " ${ aws_security_group . elasticsearch . id } "
27+ }
You can’t perform that action at this time.
0 commit comments