-
Notifications
You must be signed in to change notification settings - Fork 1
/
tgw.tf
73 lines (61 loc) · 2.67 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
resource "aws_ec2_transit_gateway" "lab" {
description = "Transit Gateway between Lab VPC A and B"
default_route_table_association = "disable"
default_route_table_propagation = "disable"
tags {
Name = "lab-tgw"
Lab = "aws-route-lab"
}
}
resource "aws_ec2_transit_gateway_route_table" "lab" {
transit_gateway_id = "${aws_ec2_transit_gateway.lab.id}"
tags {
Name = "lab-tgw-rtb"
Lab = "aws-route-lab"
}
}
resource "aws_ec2_transit_gateway_vpc_attachment" "a" {
subnet_ids = ["${aws_subnet.a.id}"]
transit_gateway_id = "${aws_ec2_transit_gateway.lab.id}"
vpc_id = "${aws_vpc.a.id}"
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags {
Name = "lab-tgw-attach-a"
Lab = "aws-route-lab"
}
}
resource "aws_ec2_transit_gateway_vpc_attachment" "b" {
subnet_ids = ["${aws_subnet.b.id}"]
transit_gateway_id = "${aws_ec2_transit_gateway.lab.id}"
vpc_id = "${aws_vpc.b.id}"
transit_gateway_default_route_table_association = false
transit_gateway_default_route_table_propagation = false
tags {
Name = "lab-tgw-attach-b"
Lab = "aws-route-lab"
}
}
resource "aws_ec2_transit_gateway_route" "to-vpc-a" {
destination_cidr_block = "${var.subnets["a"]}"
transit_gateway_attachment_id = "${aws_ec2_transit_gateway_vpc_attachment.a.id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.lab.id}"
}
resource "aws_ec2_transit_gateway_route" "to-vpc-b" {
destination_cidr_block = "${var.subnets["b"]}"
transit_gateway_attachment_id = "${aws_ec2_transit_gateway_vpc_attachment.b.id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.lab.id}"
}
resource "aws_ec2_transit_gateway_route" "to-vpc-b-outside" {
destination_cidr_block = "10.0.0.0/8"
transit_gateway_attachment_id = "${aws_ec2_transit_gateway_vpc_attachment.b.id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.lab.id}"
}
resource "aws_ec2_transit_gateway_route_table_association" "a" {
transit_gateway_attachment_id = "${aws_ec2_transit_gateway_vpc_attachment.a.id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.lab.id}"
}
resource "aws_ec2_transit_gateway_route_table_association" "b" {
transit_gateway_attachment_id = "${aws_ec2_transit_gateway_vpc_attachment.b.id}"
transit_gateway_route_table_id = "${aws_ec2_transit_gateway_route_table.lab.id}"
}