forked from rcove/aws-tgw-r8040
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tgw.tf
116 lines (98 loc) · 4.65 KB
/
tgw.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#####################################
######### Transit GW ###############
#####################################
# Create the TGW
resource "aws_ec2_transit_gateway" "transit_gateway" {
description = var.project_name
auto_accept_shared_attachments = "disable"
default_route_table_association = "disable"
default_route_table_propagation = "disable"
tags = {
Name = var.project_name
x-chkp-vpn = "${var.template_management_server_name}/${var.vpn_community_name}"
}
}
#####################################
######### Management VPC ############
#####################################
# Attach the Management VPC to the TGW
resource "aws_ec2_transit_gateway_vpc_attachment" "management_transit_gateway_vpc_attachment" {
subnet_ids = [aws_subnet.management_subnet.id]
transit_gateway_id = aws_ec2_transit_gateway.transit_gateway.id
vpc_id = aws_vpc.management_vpc.id
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags = {
Name = "${var.project_name}-Management-TGW-Attachment"
}
}
#####################################
######### Outbound VPC ##############
#####################################
# Attach the Outbound Security VPC to the TGW - This is for the management control plane
resource "aws_ec2_transit_gateway_vpc_attachment" "outbound_transit_gateway_vpc_attachment" {
subnet_ids = data.aws_subnets.outbound_subnet.ids
transit_gateway_id = aws_ec2_transit_gateway.transit_gateway.id
vpc_id = data.aws_vpc.data_outbound_asg_vpc.id
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags = {
Name = "${var.project_name}-Outbound-TGW-Attachment"
}
}
#####################################
######### Inbound VPC ###############
#####################################
# Attach the Inbound Seucirty VPC to the TGW
resource "aws_ec2_transit_gateway_vpc_attachment" "inbound_transit_gateway_vpc_attachment" {
subnet_ids = aws_subnet.inbound_subnet.*.id
transit_gateway_id = aws_ec2_transit_gateway.transit_gateway.id
vpc_id = aws_vpc.inbound_vpc.id
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags = {
Name = "${var.project_name}-Inbound-TGW-Attachment"
}
}
#####################################
######### Spoke-1 VPC ###############
#####################################
# Attach Spoke-1 VPC to the TGW
resource "aws_ec2_transit_gateway_vpc_attachment" "spoke_1_transit_gateway_vpc_attachment" {
subnet_ids = aws_subnet.spoke_1_external_subnet.*.id
transit_gateway_id = aws_ec2_transit_gateway.transit_gateway.id
vpc_id = aws_vpc.spoke_1_vpc.id
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags = {
Name = "${var.project_name}-Spoke-1-TGW-Attachment"
}
}
#####################################
######### Spoke-1a VPC ###############
#####################################
# Attach Spoke-1a VPC to the TGW
resource "aws_ec2_transit_gateway_vpc_attachment" "spoke_1a_transit_gateway_vpc_attachment" {
subnet_ids = aws_subnet.spoke_1a_external_subnet.*.id
transit_gateway_id = aws_ec2_transit_gateway.transit_gateway.id
vpc_id = aws_vpc.spoke_1a_vpc.id
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags = {
Name = "${var.project_name}-Spoke-1a-TGW-Attachment"
}
}
#####################################
######### Spoke-2 VPC ###############
#####################################
# Attach Spoek-2 VPC to the TGW
resource "aws_ec2_transit_gateway_vpc_attachment" "spoke_2_transit_gateway_vpc_attachment" {
subnet_ids = [aws_subnet.spoke_2_external_subnet.id]
transit_gateway_id = aws_ec2_transit_gateway.transit_gateway.id
vpc_id = aws_vpc.spoke_2_vpc.id
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags = {
Name = "${var.project_name}-Spoke-2-TGW-Attachment"
}
}