-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsg-api.tf
122 lines (116 loc) · 3.92 KB
/
sg-api.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
module "api_node_sg" {
source = "github.com/terraform-aws-modules/terraform-aws-security-group.git?ref=v3.2.0"
name = var.api_sg_name
description = "All traffic"
create = local.api_enabled
vpc_id = module.vpc.vpc_id
tags = merge({
Name : var.api_sg_name
}, var.tags)
ingress_with_source_security_group_id = concat(local.bastion_enabled ? [
{
rule = "ssh-tcp"
source_security_group_id = module.bastion_sg.this_security_group_id
}] : [], local.monitoring_enabled ? concat([
# static rules
{
from_port = 9100
to_port = 9100
protocol = "tcp"
description = "Node exporter"
source_security_group_id = module.monitoring_sg.this_security_group_id
},
{
from_port = 9323
to_port = 9323
protocol = "tcp"
description = "Docker Prometheus Metrics under /metrics endpoint"
source_security_group_id = module.monitoring_sg.this_security_group_id
}], [
# dynamic rules based on Polkadot network
for network in var.polkadot_network_settings : {
from_port = network["polkadot_prometheus"]
to_port = network["polkadot_prometheus"]
protocol = "tcp"
description = "Client exporter - ${network["name"]}"
source_security_group_id = module.monitoring_sg.this_security_group_id
}
]) : [], local.hids_enabled ? [
{
from_port = 1514
to_port = 1515
protocol = "tcp"
description = "wazuh agent ports for "
source_security_group_id = module.monitoring_sg.this_security_group_id
}] : [])
ingress_cidr_blocks = local.consul_enabled ? [
module.vpc.vpc_cidr_block] : []
ingress_rules = local.consul_enabled ? [
"consul-tcp",
"consul-serf-wan-tcp",
"consul-serf-wan-udp",
"consul-serf-lan-tcp",
"consul-serf-lan-udp",
"consul-dns-tcp",
"consul-dns-udp"] : []
ingress_with_cidr_blocks = concat(
concat(
# static rules
[
{
from_port = 30333
to_port = 30333
protocol = "tcp"
description = ""
cidr_blocks = "0.0.0.0/0"
},
{
from_port = 51820
to_port = 51820
protocol = "udp"
description = ""
cidr_blocks = "0.0.0.0/0"
},
], [
# dynamic rules based on Polkadot network
for network in var.polkadot_network_settings : {
from_port = network["api_health"]
to_port = network["api_health"]
protocol = "tcp"
description = "Health Check - ${network["name"]}"
cidr_blocks = "0.0.0.0/0"
}],
[
for network in var.polkadot_network_settings : {
from_port = network["json_rpc"]
to_port = network["json_rpc"]
protocol = "tcp"
description = "JSON RPC - ${network["name"]}"
cidr_blocks = "0.0.0.0/0"
}],
[
for network in var.polkadot_network_settings : {
from_port = network["ws_rpc"]
to_port = network["ws_rpc"]
protocol = "tcp"
description = "WS RPC - ${network["name"]}"
cidr_blocks = "0.0.0.0/0"
}],
), local.bastion_enabled ? [] :
[
{
from_port = 22
to_port = 22
protocol = "tcp"
description = "Security group for ssh access from coporate ip"
cidr_blocks = var.corporate_ip == "" ? "0.0.0.0/0" : "${var.corporate_ip}/32"
}], )
egress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = -1
description = "Egress access open to all"
cidr_blocks = "0.0.0.0/0"
}, ]
}