Skip to content

Instantly share code, notes, and snippets.

@SharmilaS22
Created June 18, 2023 15:03
Show Gist options
  • Save SharmilaS22/27b0fd1e46c4a644d911161312806310 to your computer and use it in GitHub Desktop.
Save SharmilaS22/27b0fd1e46c4a644d911161312806310 to your computer and use it in GitHub Desktop.
AWS Routetables for public subnet
# Internet Gateway
resource "aws_internet_gateway" "sh_gw" {
vpc_id = aws_vpc.sh_main.id
}
# route table for public subnet - connecting to Internet gateway
resource "aws_route_table" "sh_rt_public" {
vpc_id = aws_vpc.sh_main.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.sh_gw.id
}
}
# associate the route table with public subnet 1
resource "aws_route_table_association" "sh_rta1" {
subnet_id = aws_subnet.sh_subnet_1.id
route_table_id = aws_route_table.sh_rt_public.id
}
# associate the route table with public subnet 2
resource "aws_route_table_association" "sh_rta2" {
subnet_id = aws_subnet.sh_subnet_1a.id
route_table_id = aws_route_table.sh_rt_public.id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment