-
Notifications
You must be signed in to change notification settings - Fork 74
/
sg.tf
34 lines (31 loc) · 1.11 KB
/
sg.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
locals {
ingress-config = [
{ descr = "Elasticsearch port", protocol = "tcp", from_port = 9200, to_port = 9200, cidr_blocks = ["10.0.0.0/16"] },
{ descr = "Logstash ports", protocol = "tcp", from_port = 5043, to_port = 5044, cidr_blocks = ["10.0.0.0/16"] },
{ descr = "Kibana port", protocol = "tcp", from_port = 5601, to_port = 5601, cidr_blocks = ["10.0.0.0/16"] },
{ descr = "Ssh port", protocol = "tcp", from_port = 22, to_port = 22, cidr_blocks = ["0.0.0.0/0"] },
]
}
resource "aws_security_group" "elk_sg" {
name = "elk_sg"
description = "Allow all elasticsearch traffic"
vpc_id = data.terraform_remote_state.vpc.outputs.vpc_id
dynamic "ingress" {
for_each = local.ingress-config
content {
description = ingress.value.descr
from_port = ingress.value.from_port
protocol = ingress.value.protocol
to_port = ingress.value.to_port
cidr_blocks = ingress.value.cidr_blocks
}
}
# outbound
egress {
description = "Allow outbound traffic"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}