forked from itwonderlab/terraform-aws-ec2-rds-basic-free
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws_vpc_routing.tf
72 lines (61 loc) · 2.39 KB
/
aws_vpc_routing.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (C) 2018 - 2020 IT Wonder Lab (https://www.itwonderlab.com)
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.
#-----------------------------------------
# ROUTING
#-----------------------------------------
#-----------------------------------------
# MAIN Route Table (Default for all SUBNETS)
# Used for public zones / subnets
# It is the default route table if no other
# is specified
#-----------------------------------------
module "aws_main_route_table_public" {
source = "./modules/aws/network/route/table"
vpc_id = module.aws_network_vpc.id
name = var.aws_main_route_table_name
}
#Add an Internet GW to the VPC routing main table
module "aws_internet_route" {
source = "./modules/aws/network/route/add"
route_table_id = module.aws_main_route_table_public.id
gateway_id = module.aws_internet_gw.id
destination_cidr_block = var.aws_internet_route["destination_cidr_block"]
name = var.aws_internet_route["name"]
}
# Set new main_route_table as main
resource "aws_main_route_table_association" "default" {
vpc_id = module.aws_network_vpc.id
route_table_id = module.aws_main_route_table_public.id
}
#-----------------------------------------
# Private Route Table
# Used for private zone / subnet that have
# instances without a public IP address
# Each subnet should have its own route table
# as the NAT gateway lives in an availability
# zone
#-----------------------------------------
# For private networks in zone A
module "aws_private_route_table_za" {
source = "./modules/aws/network/route/table"
vpc_id = module.aws_network_vpc.id
name = var.aws_private_route_table_za_name
}
#For private networks in zone B
module "aws_private_route_table_zb" {
source = "./modules/aws/network/route/table"
vpc_id = module.aws_network_vpc.id
name = var.aws_private_route_table_zb_name
}
# Associate private networks in zone A to private route table
resource "aws_route_table_association" "route_sn_za_pro_pri_34" {
subnet_id = module.aws_sn_za_pro_pri_34.id
route_table_id = module.aws_private_route_table_za.id
}
# Associate private networks in zone B to private route table
resource "aws_route_table_association" "aws_sn_zb_pro_pri_38" {
subnet_id = module.aws_sn_zb_pro_pri_38.id
route_table_id = module.aws_private_route_table_zb.id
}