@@ -67,9 +67,9 @@ resource "aws_security_group_rule" "CE_ConanHttpFromAlb" {
6767 type = " ingress"
6868 from_port = 1080
6969 to_port = 1080
70- source_security_group_id = aws_security_group. CompilerExplorerAlb . id
70+ source_security_group_id = aws_security_group. InternalServicesAlb . id
7171 protocol = " tcp"
72- description = " Allow HTTP access from the ALB"
72+ description = " Allow HTTP access from the internal services ALB"
7373}
7474
7575resource "aws_security_group_rule" "CE_HttpsFromAlb" {
@@ -87,9 +87,9 @@ resource "aws_security_group_rule" "CE_ConanHttpsFromAlb" {
8787 type = " ingress"
8888 from_port = 1443
8989 to_port = 1443
90- source_security_group_id = aws_security_group. CompilerExplorerAlb . id
90+ source_security_group_id = aws_security_group. InternalServicesAlb . id
9191 protocol = " tcp"
92- description = " Allow HTTPS access from the ALB"
92+ description = " Allow HTTPS access from the internal services ALB"
9393}
9494
9595resource "aws_security_group" "CompilerExplorerAlb" {
@@ -101,6 +101,15 @@ resource "aws_security_group" "CompilerExplorerAlb" {
101101 }
102102}
103103
104+ resource "aws_security_group" "InternalServicesAlb" {
105+ vpc_id = module. ce_network . vpc . id
106+ name = " internal-services-alb-sg"
107+ description = " Security group for internal services load balancer (conan, etc)"
108+ tags = {
109+ Name = " InternalServicesLoadBalancer"
110+ }
111+ }
112+
104113resource "aws_security_group_rule" "ALB_HttpsFromAnywhere" {
105114 security_group_id = aws_security_group. CompilerExplorerAlb . id
106115 type = " ingress"
@@ -112,19 +121,46 @@ resource "aws_security_group_rule" "ALB_HttpsFromAnywhere" {
112121 description = " Allow HTTPS access from anywhere"
113122}
114123
115- resource "aws_security_group_rule" "ALB_ConanHttpsFromAnywhere " {
124+ resource "aws_security_group_rule" "ALB_EgressToAnywhere " {
116125 security_group_id = aws_security_group. CompilerExplorerAlb . id
126+ type = " egress"
127+ from_port = 0
128+ to_port = 65535
129+ cidr_blocks = [" 0.0.0.0/0" ]
130+ ipv6_cidr_blocks = [" ::/0" ]
131+ protocol = " -1"
132+ description = " Allow egress to anywhere"
133+ }
134+
135+ # TODO: Consider restricting these ports to CloudFront IP ranges only for better security.
136+ # Can use AWS managed prefix list: prefix_list_ids = ["pl-3b927c52"] instead of cidr_blocks.
137+ # Ports 1080/1443 are only used by conan via CloudFront, so there's no legitimate direct access.
138+ # Check with CE team before tightening to ensure no one is using direct ALB access for debugging.
139+
140+ resource "aws_security_group_rule" "InternalALB_ConanHttpsFromAnywhere" {
141+ security_group_id = aws_security_group. InternalServicesAlb . id
117142 type = " ingress"
118143 from_port = 1443
119144 to_port = 1443
120145 cidr_blocks = [" 0.0.0.0/0" ]
121146 ipv6_cidr_blocks = [" ::/0" ]
122147 protocol = " tcp"
123- description = " Allow HTTPS access from anywhere"
148+ description = " Allow HTTPS access from anywhere (port 1443 for conan) "
124149}
125150
126- resource "aws_security_group_rule" "ALB_EgressToAnywhere" {
127- security_group_id = aws_security_group. CompilerExplorerAlb . id
151+ resource "aws_security_group_rule" "InternalALB_ConanHttpFromAnywhere" {
152+ security_group_id = aws_security_group. InternalServicesAlb . id
153+ type = " ingress"
154+ from_port = 1080
155+ to_port = 1080
156+ cidr_blocks = [" 0.0.0.0/0" ]
157+ ipv6_cidr_blocks = [" ::/0" ]
158+ protocol = " tcp"
159+ description = " Allow HTTP access from anywhere (port 1080 for conan)"
160+ }
161+
162+ resource "aws_security_group_rule" "InternalALB_EgressToAnywhere" {
163+ security_group_id = aws_security_group. InternalServicesAlb . id
128164 type = " egress"
129165 from_port = 0
130166 to_port = 65535
0 commit comments