-
Notifications
You must be signed in to change notification settings - Fork 3
/
vpc-peering-connecter.tf
43 lines (37 loc) · 1.36 KB
/
vpc-peering-connecter.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
## Declare the data source
#data "aws_vpc_peering_connection" "default" {
# vpc_id = "${aws_vpc.default.id}"
# peer_vpc_id = "${aws_vpc.bursted_region.id}"
# peer_region = "${var.aws_remote_region}"
# depends_on = ["aws_vpc_peering_connection.peering"]
#}
# Create a route
resource "aws_route" "r" {
route_table_id = "${aws_vpc.default.main_route_table_id}"
destination_cidr_block = "${aws_vpc.bursted_region.cidr_block}"
vpc_peering_connection_id = "${aws_vpc_peering_connection.peering.id}"
}
## Create a route
resource "aws_route" "r-bursted" {
provider = "aws.bursted-vpc"
route_table_id = "${aws_vpc.bursted_region.main_route_table_id}"
destination_cidr_block = "${aws_vpc.default.cidr_block}"
vpc_peering_connection_id = "${aws_vpc_peering_connection.peering.id}"
}
resource "aws_vpc_peering_connection" "peering" {
vpc_id = "${aws_vpc.default.id}"
peer_vpc_id = "${aws_vpc.bursted_region.id}"
peer_region = "${var.aws_remote_region}"
tags {
Name = "VPC Peering between default and bursting"
}
}
# Accepter's side of the connection.
resource "aws_vpc_peering_connection_accepter" "peer" {
provider = "aws.bursted-vpc"
vpc_peering_connection_id = "${aws_vpc_peering_connection.peering.id}"
auto_accept = true
tags {
Side = "Accepter"
}
}