1
1
# Create an Application Load Balancer (ALB)
2
2
resource "aws_lb" "httpd_alb" {
3
3
name = " ${ var . project } -${ var . venue } -httpd-alb"
4
- internal = false
4
+ internal = true
5
5
load_balancer_type = " application"
6
6
security_groups = [aws_security_group . ecs_alb_sg . id ]
7
- subnets = local. public_subnet_ids
7
+ subnets = local. subnet_ids
8
8
enable_deletion_protection = false
9
9
preserve_host_header = true
10
10
tags = {
@@ -110,16 +110,6 @@ resource "aws_vpc_security_group_ingress_rule" "ecs_alb_ingress_sg_rule" {
110
110
referenced_security_group_id = aws_security_group. ecs_alb_sg . id
111
111
}
112
112
113
- # Add a new ingress rule to the ECS ALB's security group, opening it up to other connections
114
- # tfsec:ignore:AVD-AWS-0107
115
- resource "aws_vpc_security_group_ingress_rule" "alb_all_ingress_sg_rule" {
116
- security_group_id = aws_security_group. ecs_alb_sg . id
117
- to_port = 8080
118
- from_port = 8080
119
- ip_protocol = " tcp"
120
- cidr_ipv4 = " 0.0.0.0/0"
121
- }
122
-
123
113
# Add a new egress rule to the ECS's security group, allowing ECS to fetch the container images/proxy
124
114
resource "aws_vpc_security_group_egress_rule" "ecs_egress_sg_rule" {
125
115
security_group_id = aws_security_group. ecs_sg . id
@@ -137,3 +127,23 @@ resource "aws_vpc_security_group_egress_rule" "ecs_alb_egress_sg_rule" {
137
127
ip_protocol = " tcp"
138
128
cidr_ipv4 = " 0.0.0.0/0"
139
129
}
130
+
131
+ data "aws_ssm_parameter" "shared-services_security_group" {
132
+ name = " arn:aws:ssm:${ data . aws_ssm_parameter . shared_service_region . value } :${ data . aws_ssm_parameter . shared_service_account_id . value } :parameter/unity/shared-services/network/httpd_security_group"
133
+ }
134
+
135
+ resource "aws_vpc_security_group_ingress_rule" "ecs_alb_sg_ingress_rule" {
136
+ security_group_id = aws_security_group. ecs_alb_sg . id
137
+ from_port = 8080
138
+ to_port = 8080
139
+ ip_protocol = " tcp"
140
+ referenced_security_group_id = data. aws_ssm_parameter . shared-services_security_group . value
141
+ }
142
+
143
+ resource "aws_vpc_security_group_egress_rule" "ecs_sg_egress_rule" {
144
+ security_group_id = aws_security_group. ecs_sg . id
145
+ from_port = 0
146
+ to_port = 65535
147
+ ip_protocol = " tcp"
148
+ referenced_security_group_id = data. aws_security_group . mc_alb_sg . id
149
+ }
0 commit comments