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-secondary.tf
73 lines (56 loc) · 1.98 KB
/
peering-secondary.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
### THIS BLOCK ACCEPTS CONNECTIONS FROM PRIMARY REGION
resource "aws_vpc_peering_connection_accepter" "secondary-primary" {
provider = aws.secondary
vpc_peering_connection_id = aws_vpc_peering_connection.primary-secondary.id
auto_accept = true
tags = {
Side = "Accepter"
prefix = var.prefix
}
}
resource "aws_vpc_peering_connection_options" "secondary-primary" {
provider = aws.secondary
vpc_peering_connection_id = aws_vpc_peering_connection.primary-secondary.id
accepter {
allow_remote_vpc_dns_resolution = true
}
depends_on = [aws_vpc_peering_connection_accepter.secondary-primary]
}
resource "aws_route" "secondary-primary" {
provider = aws.secondary
route_table_id = module.secondary_network.vpc.main_route_table_id
destination_cidr_block = var.vpc_cidrs[0]
vpc_peering_connection_id = aws_vpc_peering_connection.primary-secondary.id
timeouts {
create = "5m"
}
}
### THIS BLOCK CREATES CONNECTIONS TO TERTIARY REGION
resource "aws_vpc_peering_connection" "secondary-tertiary" {
provider = aws.secondary
peer_vpc_id = module.tertiary_network.vpc.id
peer_region = var.aws_regions[2]
vpc_id = module.secondary_network.vpc.id
auto_accept = false
tags = {
Side = "Requester"
prefix = var.prefix
}
}
resource "aws_route" "secondary-tertiary" {
provider = aws.secondary
route_table_id = module.secondary_network.vpc.main_route_table_id
destination_cidr_block = var.vpc_cidrs[2]
vpc_peering_connection_id = aws_vpc_peering_connection.secondary-tertiary.id
timeouts {
create = "5m"
}
}
resource "aws_vpc_peering_connection_options" "secondary-tertiary" {
provider = aws.secondary
vpc_peering_connection_id = aws_vpc_peering_connection.secondary-tertiary.id
requester {
allow_remote_vpc_dns_resolution = true
}
depends_on = [aws_vpc_peering_connection_accepter.tertiary-secondary]
}