-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
105 lines (82 loc) · 1.87 KB
/
main.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
resource "aws_vpc" "local" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "local1" {
vpc_id = aws_vpc.local1.id
cidr_block = "10.0.1.0/24"
tags = {
Name = "Local1"
}
}
resource "aws_subnet" "local2" {
vpc_id = aws_vpc.local2.id
cidr_block = "10.0.2.0/24"
tags = {
Name = "Local2"
}
}
resource"aws_vpc" "remote" {
cidr_block = "11.0.0.0/16"
}
resource "aws_subnet" "remote1" {
vpc_id = aws_vpc.remote1.id
cidr_block = "11.0.1.0/24"
tags = {
Name = "Remote1"
}
}
resource "aws_subnet" "remote2" {
vpc_id = aws_vpc.remote2.id
cidr_block = "11.0.2.0/24"
tags = {
Name = "Remote2"
}
}
resource "aws_ec2_transit_gateway" "local-tgw" {
description = "local_tgw"
tags = {
"Name" = "local-tgw"
}
}
resource "aws_ec2_transit_gateway" "remote-tgw" {
description = "remote_tgw"
tags = {
"Name" = "remote-tgw"
}
}
resource "aws_route_table" "localr" {
vpc_id = aws_vpc.local1.id
tags = {
Name = "local_main"
}
}
resource "aws_route_table" "remoter" {
vpc_id = aws_vpc.remote1.id
tags = {
Name = "remote_main"
}
}
resource "aws_ec2_transit_gateway_vpc_attachment" "local1" {
subnet_ids = [aws_subnet.local1.id]
transit_gateway_id = aws_ec2_transit_gateway.local1.id
vpc_id = aws_vpc.local.id
tags = {
Name = "local_tgw_attach"
}
}
resource "aws_ec2_transit_gateway_vpc_attachment" "remote1" {
subnet_ids = [aws_subnet.remote1.id]
transit_gateway_id = aws_ec2_transit_gateway.remote1.id
vpc_id = aws_vpc.remote.id
tags = {
Name = "local_tgw_attach"
}
}
resource "aws_ec2_transit_gateway_vpc_attachment_accepter" "test1" {
transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.test1.id
vpc_id = aws_vpc.local.id
subnet_ids = aws_subnet.local1[*].vpc_id
tags = {
Name = "local_tgw_attach"
}
}