Skip to content

Commit 47af1bf

Browse files
author
Miguel Elhaiek
committed
Modifying NLB for ALB to try HTTP health checks on ECS between target group and the app
1 parent 803ffd4 commit 47af1bf

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

terraform/main.tf

+28-33
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,23 @@ resource "aws_route_table_association" "vectorstore_rta" {
5858

5959

6060

61+
# resource "aws_lb" "vectorstore_nlb" {
62+
# name = "vectorstore-nlb"
63+
# internal = true #INTERNAL NLB, ONLY ACCESSIBLE VIA VPC LINK
64+
# load_balancer_type = "network"
65+
# subnets = [aws_subnet.vectorstore_subnet.id]
66+
# enable_deletion_protection = false
67+
68+
# tags = {
69+
# Name = "vectorstore_nlb"
70+
# }
71+
# }
72+
73+
6174
resource "aws_lb" "vectorstore_nlb" {
6275
name = "vectorstore-nlb"
6376
internal = true #INTERNAL NLB, ONLY ACCESSIBLE VIA VPC LINK
64-
load_balancer_type = "network"
77+
load_balancer_type = "application"
6578
subnets = [aws_subnet.vectorstore_subnet.id]
6679
enable_deletion_protection = false
6780

@@ -70,6 +83,8 @@ resource "aws_lb" "vectorstore_nlb" {
7083
}
7184
}
7285

86+
87+
7388
# resource "aws_lb_target_group" "vectorstore_tg" {
7489
# name = "vectorstore-tg"
7590
# port = 19530
@@ -104,9 +119,10 @@ resource "aws_security_group" "nlb_sg" {
104119
# }
105120

106121
# port for ECS fargate container API:
122+
# 19531
107123
ingress {
108-
from_port = 19531
109-
to_port = 19531
124+
from_port = 80 #http traffic from ALB
125+
to_port = 80
110126
protocol = "tcp"
111127
cidr_blocks = ["0.0.0.0/0"]
112128
}
@@ -149,15 +165,15 @@ resource "aws_security_group" "milvus_sg_api" {
149165

150166

151167

152-
# Modify your EC2 instance security group to only allow traffic from the NLB security group
153-
resource "aws_security_group_rule" "allow_nlb_to_ec2" {
154-
type = "ingress"
155-
from_port = 19530
156-
to_port = 19530
157-
protocol = "tcp"
158-
security_group_id = aws_security_group.milvus_sg_api.id
159-
source_security_group_id = aws_security_group.nlb_sg.id
160-
}
168+
# # Modify your EC2 instance security group to only allow traffic from the NLB security group
169+
# resource "aws_security_group_rule" "allow_nlb_to_ec2" {
170+
# type = "ingress"
171+
# from_port = 19530
172+
# to_port = 19530
173+
# protocol = "tcp"
174+
# security_group_id = aws_security_group.milvus_sg_api.id
175+
# source_security_group_id = aws_security_group.nlb_sg.id
176+
# }
161177

162178
resource "aws_instance" "milvus_instance" {
163179
ami = var.ami
@@ -181,27 +197,6 @@ resource "aws_instance" "milvus_instance" {
181197
}
182198

183199

184-
# resource "aws_instance" "milvus_instance" {
185-
# ami = var.ami
186-
# instance_type = var.instance_type
187-
# key_name = var.key_name
188-
# subnet_id = aws_subnet.vectorstore_subnet.id
189-
# vpc_security_group_ids = [aws_security_group.milvus_sg_api.id]
190-
# associate_public_ip_address = true // This line assigns a public IP address to your instance
191-
192-
# user_data = file("${path.module}/../create-milvus.sh")
193-
194-
# root_block_device {
195-
# volume_size = 30
196-
# }
197-
198-
# tags = {
199-
# Name = "Milvus-db-for-api"
200-
# }
201-
# }
202-
203-
204-
205200
# create SSMRoleForEC2 that the EC2 instance needs to assume to connect via System Manager , instead of via SSH
206201

207202
resource "aws_iam_role" "ssm_role" {

0 commit comments

Comments
 (0)