-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecurity-group.tf
137 lines (119 loc) · 3.88 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
128
129
130
131
132
133
134
135
136
137
data "aws_subnet" "this" {
id = var.broker_subnets[0]
}
locals {
vpc_id = data.aws_subnet.this.vpc_id
}
###################################################
# Security Group
###################################################
module "security_group" {
source = "tedilabs/network/aws//modules/security-group"
version = "~> 0.32.0"
name = "msk-${var.name}"
description = "Security group for MSK Cluster."
vpc_id = local.vpc_id
ingress_rules = concat(
contains(["PLAINTEXT", "TLS_PLAINTEXT"], var.encryption_in_transit.client_mode) ? [
{
id = "broker-plaintext/cidrs"
description = "Allow CIDRs to communicate with Kafka brokers in plaintext."
protocol = "tcp"
from_port = 9092
to_port = 9092
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
] : [],
contains(["TLS", "TLS_PLAINTEXT"], var.encryption_in_transit.client_mode) ? [
{
id = "broker-tls/cidrs"
description = "Allow CIDRs to communicate with Kafka brokers in tls."
protocol = "tcp"
from_port = 9094
to_port = 9094
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
] : [],
var.authentication.sasl_scram.enabled ? [
{
id = "broker-sasl-scram/cidrs"
description = "Allow CIDRs to communicate with Kafka brokers in SASL SCRAM."
protocol = "tcp"
from_port = 9096
to_port = 9096
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
] : [],
var.authentication.sasl_iam.enabled ? [
{
id = "broker-sasl-iam/cidrs"
description = "Allow CIDRs to communicate with Kafka brokers in SASL IAM."
protocol = "tcp"
from_port = 9098
to_port = 9098
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
] : [],
[
{
id = "broker-public-tls/cidrs"
description = "Allow CIDRs to communicate with Kafka brokers in tls (public)."
protocol = "tcp"
from_port = 9194
to_port = 9194
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
{
id = "broker-public-sasl-scram/cidrs"
description = "Allow CIDRs to communicate with Kafka brokers in SASL SCRAM (public)."
protocol = "tcp"
from_port = 9196
to_port = 9196
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
{
id = "broker-public-sasl-iam/cidrs"
description = "Allow CIDRs to communicate with Kafka brokers in SASL IAM (public)."
protocol = "tcp"
from_port = 9198
to_port = 9198
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
{
id = "zookeeper/cidrs"
description = "Allow CIDRs to communicate with Kafka zookeepers."
protocol = "tcp"
from_port = 2181
to_port = 2181
ipv4_cidrs = var.broker_allowed_ingress_cidrs
},
],
var.prometheus.jmx_exporter_enabled ? [
{
id = "prometheus-jmx-exporter/cidrs"
description = "Allow CIDRs to communicate with Prometheus JMX Exporter."
protocol = "tcp"
from_port = 11001
to_port = 11001
ipv4_cidrs = var.prometheus.allowed_ingress_ipv4_cidrs
},
] : [],
var.prometheus.node_exporter_enabled ? [
{
id = "prometheus-node-exporter/cidrs"
description = "Allow CIDRs to communicate with Prometheus Node Exporter."
protocol = "tcp"
from_port = 11002
to_port = 11002
ipv4_cidrs = var.prometheus.allowed_ingress_ipv4_cidrs
},
] : [],
)
revoke_rules_on_delete = true
resource_group_enabled = false
module_tags_enabled = false
tags = merge(
local.module_tags,
var.tags,
)
}