-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
71 lines (56 loc) · 2.66 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
#--------------------------------------------------------------
# VPC Peering Requester
#--------------------------------------------------------------
resource "aws_vpc_peering_connection" "requester" {
count = "${var.requester ? 1 : 0}"
peer_owner_id = "${var.accepter_owner_id}"
peer_vpc_id = "${var.accepter_vpc_id}"
peer_region = "${var.accepter_region}"
vpc_id = "${var.requester_vpc_id}"
auto_accept = "${var.auto_accept}"
tags = "${merge(var.requester_tags, var.tags)}"
}
# Routes
resource "aws_route" "requester_table" {
count = "${var.requester && length(var.requester_route_table_ids) > 0 ? length(var.requester_route_table_ids) : 0}"
route_table_id = "${var.requester_route_table_ids[count.index]}"
destination_cidr_block = "${var.accepter_cidr_block}"
vpc_peering_connection_id = "${aws_vpc_peering_connection.requester.id}"
}
#--------------------------------------------------------------
# VPC Peering Requester Options
#--------------------------------------------------------------
resource "aws_vpc_peering_connection_options" "requester" {
count = "${var.requester_options ? 1 : 0}"
vpc_peering_connection_id = "${var.vpc_peering_connection_id}"
requester {
allow_remote_vpc_dns_resolution = "${var.allow_remote_vpc_dns_resolution}"
allow_classic_link_to_remote_vpc = "${var.allow_classic_link_to_remote_vpc}"
allow_vpc_to_remote_classic_link = "${var.allow_vpc_to_remote_classic_link}"
}
}
#--------------------------------------------------------------
# VPC Peering Accepter
#--------------------------------------------------------------
resource "aws_vpc_peering_connection_accepter" "side" {
count = "${var.accepter ? 1 : 0}"
vpc_peering_connection_id = "${var.vpc_peering_connection_id}"
auto_accept = "${var.auto_accept}"
tags = "${merge(var.accepter_tags, var.tags)}"
}
resource "aws_vpc_peering_connection_options" "accepter" {
count = "${var.accepter ? 1 : 0}"
vpc_peering_connection_id = "${aws_vpc_peering_connection_accepter.side.id}"
accepter {
allow_remote_vpc_dns_resolution = "${var.allow_remote_vpc_dns_resolution}"
allow_classic_link_to_remote_vpc = "${var.allow_classic_link_to_remote_vpc}"
allow_vpc_to_remote_classic_link = "${var.allow_vpc_to_remote_classic_link}"
}
}
# Routes
resource "aws_route" "accepter_table" {
count = "${var.accepter && length(var.accepter_route_table_ids) > 0 ? length(var.accepter_route_table_ids) : 0}"
vpc_peering_connection_id = "${aws_vpc_peering_connection_accepter.side.id}"
route_table_id = "${var.accepter_route_table_ids[count.index]}"
destination_cidr_block = "${var.requester_cidr_block}"
}