* Fixing NAT gateway for proper usage from crete members

With this patch members of Crete can now get system patches
This commit is contained in:
shockrah 2021-11-28 15:24:26 -08:00
parent 157e2db453
commit 17c1e3467b
3 changed files with 32 additions and 9 deletions

View File

@ -15,6 +15,7 @@ resource "aws_eip" "gamma_eip" {
} }
} }
# This EIP is reserved for the NAT gateway which lives in Olympus
resource "aws_eip" "demeter_eip" { resource "aws_eip" "demeter_eip" {
vpc = true vpc = true
tags = { tags = {

View File

@ -1,16 +1,21 @@
# Used to provide internet access for instances in the VPC
resource "aws_internet_gateway" "athens_internet_gateway" { resource "aws_internet_gateway" "athens_internet_gateway" {
vpc_id = aws_vpc.athens_vpc.id vpc_id = aws_vpc.athens_vpc.id
tags = { tags = {
Name = "Athens Common Internet Gateway" Name = "Athens Common Internet Gateway in Olypmus"
} }
} }
resource "aws_nat_gateway" "athens_nat_gateway" { # NAT lives in the public subnet because it has an EIP
# which is the main requirement to be situated in Olympus
resource "aws_nat_gateway" "crete_nat_gateway" {
allocation_id = aws_eip.demeter_eip.id allocation_id = aws_eip.demeter_eip.id
subnet_id = aws_subnet.crete_subnet.id subnet_id = aws_subnet.olympus_subnet.id
tags = { tags = {
Name = "Demeter - Crete' NAT" Name = "Demeter - Crete's NAT located in Olympus"
} }
# Ensure this resource is created after the internet gateway
depends_on = [aws_internet_gateway.athens_internet_gateway]
} }

View File

@ -1,17 +1,34 @@
resource "aws_route_table" "crete_route_table" { # NOTE: local traffic route is implied and does not need to be specified
resource "aws_route_table" "olympus_route_table" {
vpc_id = aws_vpc.athens_vpc.id vpc_id = aws_vpc.athens_vpc.id
route { route {
# ????
cidr_block = "0.0.0.0/0" cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.athens_internet_gateway.id gateway_id = aws_internet_gateway.athens_internet_gateway.id
} }
tags = { tags = {
Name = "Crete Route Table" Name = "Olympush IGW Route Table"
} }
} }
resource "aws_route_table_association" "olympus_gateway_association" {
subnet_id = aws_subnet.olympus_subnet.id
route_table_id = aws_route_table.olympus_route_table.id
}
resource "aws_route_table_association" "crete_gateway_association" {
# Here we route crete's traffic to the nat
# NOTE: The NAT is actually located in Olympus because it has an EIP
resource "aws_route_table" "crete_route_table" {
vpc_id = aws_vpc.athens_vpc.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.crete_nat_gateway.id
}
tags = {
Name = "Crete NAT Route Table"
}
}
resource "aws_route_table_association" "crete_nat_association" {
subnet_id = aws_subnet.crete_subnet.id subnet_id = aws_subnet.crete_subnet.id
route_table_id = aws_route_table.crete_route_table.id route_table_id = aws_route_table.crete_route_table.id
} }