Created
June 18, 2023 15:03
-
-
Save SharmilaS22/27b0fd1e46c4a644d911161312806310 to your computer and use it in GitHub Desktop.
AWS Routetables for public subnet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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