-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsecurity-group.tf
127 lines (112 loc) · 2.65 KB
/
security-group.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
locals {
my_ip = "89.134.0.15/32" # Replace YOUR_IP_ADDRESS with your actual IP address
ingress_rules = [{
name = "HTTPS"
port = 443
description = "Ingress rules for port 443"
},
{
name = "Monitoring"
port = 3000
description = "Ingress rules for port 3000"
},
{
name = "HTTP"
port = 80
description = "Ingress rules for port 80"
},
{
name = "SSH"
port = 22
description = "Ingress rules for port 22"
},
{
name = "CQL"
port = 9042
description = "Ingress rules for ScyllaDB"
},
{
name = "SSL CQL"
port = 9142
},
{
name = "rpc"
port = 7000
description = "Ingress rules for ScyllaDB"
},
{
name = "RPC SSL"
port = 7001
description = "Ingress rules for ScyllaDB"
},
{
name = "JMX"
port = 7199
description = "Ingress rules for ScyllaDB"
},
{
name = "REST"
port = 10000
description = "Ingress rules for ScyllaDB"
},
{
name = "Prometheus"
port = 9180
description = "Ingress rules for ScyllaDB"
},
{
name = "Node exp"
port = 9100
description = "Ingress rules for ScyllaDB"
},
{
name = "Thirft"
port = 9160
description = "Ingress rules for ScyllaDB"
},
{
name = "shard-aware"
port = 19042
description = "Ingress rules for ScyllaDB"
}]
}
resource "aws_security_group" "sg" {
name = "${var.custom_name}-sg"
description = "Allow TLS inbound traffic"
vpc_id = aws_vpc.custom_vpc.id
egress = [
{
description = "for all outgoing traffics"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
prefix_list_ids = []
security_groups = []
self = false
}
]
dynamic "ingress" {
for_each = local.ingress_rules
content {
# description = ingress.value.description
from_port = ingress.value.port
to_port = ingress.value.port
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
ingress {
description = "Allow access to port 3000 from my IP"
from_port = 3000
to_port = 3000
protocol = "tcp"
cidr_blocks = [local.my_ip]
}
tags = {
Name = "${var.custom_name}-SG"
"Project" = "${var.custom_name}"
"Type" = "SG"
}
}