File tree Expand file tree Collapse file tree 5 files changed +75
-6
lines changed Expand file tree Collapse file tree 5 files changed +75
-6
lines changed Original file line number Diff line number Diff line change 1+ resource "aws_internet_gateway" "gw" {
2+ vpc_id = " ${ aws_vpc . vpc_demo . id } "
3+
4+ tags = {
5+ Name = " internet-gateway-demo"
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ resource "aws_eip" "nat" {
2+ vpc = true
3+ }
4+
5+ resource "aws_nat_gateway" "nat_gw" {
6+ allocation_id = " ${ aws_eip . nat . id } "
7+ subnet_id = " ${ aws_subnet . public_1 . id } "
8+ depends_on = [" aws_internet_gateway.gw" ]
9+ }
10+
11+ resource "aws_route_table" "route_private" {
12+ vpc_id = " ${ aws_vpc . vpc_demo . id } "
13+
14+ route {
15+ cidr_block = " 10.0.0.0/0"
16+ gateway_id = " ${ aws_nat_gateway . nat_gw . id } "
17+ }
18+
19+ tags = {
20+ Name = " private-route-table-demo"
21+ }
22+ }
23+
24+ resource "aws_route_table_association" "private_1" {
25+ subnet_id = " ${ aws_subnet . private_1 . id } "
26+ route_table_id = " ${ aws_route_table . route_private . id } "
27+ }
28+ resource "aws_route_table_association" "private_2" {
29+ subnet_id = " ${ aws_subnet . private_2 . id } "
30+ route_table_id = " ${ aws_route_table . route_private . id } "
31+ }
32+ resource "aws_route_table_association" "private_3" {
33+ subnet_id = " ${ aws_subnet . private_3 . id } "
34+ route_table_id = " ${ aws_route_table . route_private . id } "
35+ }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ resource "aws_subnet" "private_1" {
44 cidr_block = " 10.0.4.0/24"
55
66 tags = {
7- Name = " private_1"
7+ Name = " private_1-demo "
88 }
99}
1010resource "aws_subnet" "private_2" {
@@ -13,7 +13,7 @@ resource "aws_subnet" "private_2" {
1313 cidr_block = " 10.0.5.0/24"
1414
1515 tags = {
16- Name = " private_1 "
16+ Name = " private_2-demo "
1717 }
1818}
1919resource "aws_subnet" "private_3" {
@@ -22,6 +22,6 @@ resource "aws_subnet" "private_3" {
2222 cidr_block = " 10.0.6.0/24"
2323
2424 tags = {
25- Name = " private_1 "
25+ Name = " private_3-demo "
2626 }
2727}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ resource "aws_subnet" "public_1" {
44 cidr_block = " 10.0.1.0/24"
55
66 tags = {
7- Name = " public_1"
7+ Name = " public_1-demo "
88 }
99}
1010resource "aws_subnet" "public_2" {
@@ -13,7 +13,7 @@ resource "aws_subnet" "public_2" {
1313 cidr_block = " 10.0.2.0/24"
1414
1515 tags = {
16- Name = " public_1 "
16+ Name = " public_2-demo "
1717 }
1818}
1919resource "aws_subnet" "public_3" {
@@ -22,6 +22,6 @@ resource "aws_subnet" "public_3" {
2222 cidr_block = " 10.0.3.0/24"
2323
2424 tags = {
25- Name = " public_1 "
25+ Name = " public_3-demo "
2626 }
2727}
Original file line number Diff line number Diff line change 1+ resource "aws_route_table" "route-public" {
2+ vpc_id = " ${ aws_vpc . vpc_demo . id } "
3+
4+ route {
5+ cidr_block = " 10.0.0.0/0"
6+ gateway_id = " ${ aws_internet_gateway . gw . id } "
7+ }
8+
9+ tags = {
10+ Name = " public-route-table-demo"
11+ }
12+ }
13+
14+ resource "aws_route_table_association" "public_1" {
15+ subnet_id = " ${ aws_subnet . public_1 . id } "
16+ route_table_id = " ${ aws_route_table . route-public . id } "
17+ }
18+
19+ resource "aws_route_table_association" "public_2" {
20+ subnet_id = " ${ aws_subnet . public_2 . id } "
21+ route_table_id = " ${ aws_route_table . route-public . id } "
22+ }
23+
24+ resource "aws_route_table_association" "public_3" {
25+ subnet_id = " ${ aws_subnet . public_3 . id } "
26+ route_table_id = " ${ aws_route_table . route-public . id } "
27+ }
You can’t perform that action at this time.
0 commit comments