From 6657c54a83720ff126b4fb3ca89a9ee0922ca948 Mon Sep 17 00:00:00 2001 From: Miguel Elhaiek Date: Mon, 8 Apr 2024 12:08:32 -0300 Subject: [PATCH] Adding second subnet for ALB setup --- .github/workflows/build_and_deploy.yml | 6 +++--- terraform/main.tf | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 97c7d72..943e362 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -36,9 +36,9 @@ jobs: run: terraform init working-directory: terraform - - name: Terraform Refresh - run: terraform refresh - working-directory: terraform + # - name: Terraform Refresh + # run: terraform refresh + # working-directory: terraform - name: Terraform Plan run: terraform plan -out=tfplan diff --git a/terraform/main.tf b/terraform/main.tf index bc1c4d7..76081f2 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -31,6 +31,17 @@ resource "aws_subnet" "vectorstore_subnet" { } } +# Second subnet in a different Availability Zone (For ALB to work) +resource "aws_subnet" "vectorstore_subnet_2" { + vpc_id = aws_vpc.vectorstore_vpc.id + cidr_block = "10.0.2.0/24" + availability_zone = "us-east-1b" # Change this to a different zone from the first subnet + tags = { + Name = "vectorstore_subnet_2" + } +} + + resource "aws_internet_gateway" "vectorstore_igw" { vpc_id = aws_vpc.vectorstore_vpc.id tags = { @@ -75,7 +86,7 @@ resource "aws_lb" "vectorstore_nlb" { name = "vectorstore-nlb" internal = true #INTERNAL NLB, ONLY ACCESSIBLE VIA VPC LINK load_balancer_type = "application" - subnets = [aws_subnet.vectorstore_subnet.id] + subnets = [aws_subnet.vectorstore_subnet.id, aws_subnet.vectorstore_subnet_2.id] enable_deletion_protection = false tags = {