This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
peering-primary.tf
77 lines (58 loc) · 1.97 KB
/
peering-primary.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
### THIS BLOCK CREATES CONNECTIONS TO SECONDARY REGION
resource "aws_vpc_peering_connection" "primary-secondary" {
provider = aws.primary
peer_vpc_id = module.secondary_network.vpc.id
peer_region = var.aws_regions[1]
vpc_id = module.primary_network.vpc.id
auto_accept = false
tags = {
Side = "Requester"
prefix = var.prefix
}
}
resource "aws_route" "primary-secondary" {
provider = aws.primary
route_table_id = module.primary_network.vpc.main_route_table_id
destination_cidr_block = var.vpc_cidrs[1]
vpc_peering_connection_id = aws_vpc_peering_connection.primary-secondary.id
timeouts {
create = "5m"
}
}
resource "aws_vpc_peering_connection_options" "primary-secondary" {
provider = aws.primary
vpc_peering_connection_id = aws_vpc_peering_connection.primary-secondary.id
requester {
allow_remote_vpc_dns_resolution = true
}
depends_on = [aws_vpc_peering_connection_accepter.secondary-primary]
}
### THIS BLOCK CREATES CONNECTIONS TO TERTIARY REGION
resource "aws_vpc_peering_connection_options" "primary-tertiary" {
provider = aws.primary
vpc_peering_connection_id = aws_vpc_peering_connection.primary-tertiary.id
requester {
allow_remote_vpc_dns_resolution = true
}
depends_on = [aws_vpc_peering_connection_accepter.tertiary-primary]
}
resource "aws_vpc_peering_connection" "primary-tertiary" {
provider = aws.primary
peer_vpc_id = module.tertiary_network.vpc.id
peer_region = var.aws_regions[2]
vpc_id = module.primary_network.vpc.id
auto_accept = false
tags = {
Side = "Requester"
prefix = var.prefix
}
}
resource "aws_route" "primary-tertiary" {
provider = aws.primary
route_table_id = module.primary_network.vpc.main_route_table_id
destination_cidr_block = var.vpc_cidrs[2]
vpc_peering_connection_id = aws_vpc_peering_connection.primary-tertiary.id
timeouts {
create = "5m"
}
}