@@ -3,15 +3,6 @@ resource "aws_security_group" "alb_sg" {
33 description = " Allow inbound traffic"
44 vpc_id = var. vpc_id
55
6- # ingress {
7- # from_port = 443
8- # to_port = 443
9- # protocol = "tcp"
10- # cidr_blocks = ["0.0.0.0/0"]
11- # }
12-
13- # I don't know why, but it only works when all traffic is allowed.
14- # Edit the ECS security group instead.
156 ingress {
167 from_port = 0
178 to_port = 0
@@ -33,39 +24,32 @@ resource "aws_security_group" "backend_sg" {
3324 description = " SG for ECS EC2"
3425 vpc_id = var. vpc_id
3526
36- # ingress {
37- # from_port = 80
38- # to_port = 80
39- # protocol = "tcp"
40- # security_groups = [aws_security_group.alb_sg.id]
41- # }
42-
43- # ingress {
44- # from_port = 443
45- # to_port = 443
46- # protocol = "tcp"
47- # security_groups = [aws_security_group.alb_sg.id]
48- # }
49-
50- # ingress {
51- # from_port = 8000
52- # to_port = 8000
53- # protocol = "tcp"
54- # security_groups = [aws_security_group.alb_sg.id]
55- # }
56-
57- # egress {
58- # from_port = 0
59- # to_port = 0
60- # protocol = "-1"
61- # cidr_blocks = ["0.0.0.0/0"]
62- # }
27+ ingress {
28+ from_port = 80
29+ to_port = 80
30+ protocol = " tcp"
31+ security_groups = [aws_security_group . alb_sg . id ]
32+ }
6333
6434 ingress {
65- from_port = 0
66- to_port = 0
67- protocol = " -1"
68- cidr_blocks = [" 0.0.0.0/0" ]
35+ from_port = 443
36+ to_port = 443
37+ protocol = " tcp"
38+ security_groups = [aws_security_group . alb_sg . id ]
39+ }
40+
41+ ingress {
42+ from_port = 8000
43+ to_port = 8000
44+ protocol = " tcp"
45+ security_groups = [aws_security_group . alb_sg . id ]
46+ }
47+
48+ ingress {
49+ from_port = 9092
50+ to_port = 9092
51+ protocol = " tcp"
52+ security_groups = [aws_security_group . msk_sg . id ]
6953 }
7054
7155 egress {
@@ -86,10 +70,10 @@ resource "aws_security_group" "service_sg" {
8670 vpc_id = var. vpc_id
8771
8872 ingress {
89- from_port = 0
90- to_port = 0
91- protocol = " -1 "
92- cidr_blocks = [" 0.0.0.0/0 " ]
73+ from_port = 9092
74+ to_port = 9092
75+ protocol = " tcp "
76+ security_groups = [aws_security_group . msk_sg . id ]
9377 }
9478
9579 egress {
@@ -106,9 +90,9 @@ resource "aws_security_group" "msk_sg" {
10690 vpc_id = var. vpc_id
10791
10892 ingress {
109- from_port = 0
110- to_port = 0
111- protocol = " -1 "
93+ from_port = 9092
94+ to_port = 9092
95+ protocol = " tcp "
11296 cidr_blocks = [" 0.0.0.0/0" ]
11397 }
11498
@@ -126,10 +110,10 @@ resource "aws_security_group" "lambda_msk_sg" {
126110 vpc_id = var. vpc_id
127111
128112 ingress {
129- from_port = 0
130- to_port = 0
131- protocol = " -1 "
132- cidr_blocks = [" 0.0.0.0/0 " ]
113+ from_port = 9092
114+ to_port = 9092
115+ protocol = " tcp "
116+ security_groups = [aws_security_group . msk_sg . id ]
133117 }
134118
135119 egress {
0 commit comments