-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from QuiNovas/develop
Develop
- Loading branch information
Showing
7 changed files
with
89 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea/ | ||
*.iml | ||
.terraform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
data "aws_caller_identity" "accepter" { | ||
provider = "aws.accepter" | ||
provider = aws.accepter | ||
} | ||
|
||
data "aws_region" "accepter" { | ||
provider = "aws.accepter" | ||
provider = aws.accepter | ||
} | ||
|
||
data "aws_vpc" "accepter" { | ||
id = "${var.accepter_vpc_id}" | ||
provider = "aws.accepter" | ||
id = var.accepter_vpc_id | ||
provider = aws.accepter | ||
} | ||
|
||
data "aws_vpc" "requester" { | ||
id = "${var.requester_vpc_id}" | ||
provider = "aws.requester" | ||
id = var.requester_vpc_id | ||
provider = aws.requester | ||
} | ||
|
||
data "aws_route_tables" "accepter" { | ||
provider = "aws.accepter" | ||
vpc_id = "${var.accepter_vpc_id}" | ||
provider = aws.accepter | ||
vpc_id = var.accepter_vpc_id | ||
} | ||
|
||
data "aws_route_tables" "requester" { | ||
provider = "aws.requester" | ||
vpc_id = "${var.requester_vpc_id}" | ||
} | ||
provider = aws.requester | ||
vpc_id = var.requester_vpc_id | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
locals { | ||
accepter_route_table_ids = "${split(",", local.accepter_route_table_ids_join)}" | ||
accepter_route_table_ids_join = "${var.accepter_route_table_ids_count > 0 ? join(",", var.accepter_route_table_ids) : join(",", data.aws_route_tables.accepter.ids)}" | ||
accepter_route_table_ids_count = "${var.accepter_route_table_ids_count > 0 ? var.accepter_route_table_ids_count : length(data.aws_route_tables.accepter.ids)}" | ||
requester_route_table_ids = "${split(",", local.requester_route_table_ids_join)}" | ||
requester_route_table_ids_join = "${var.requester_route_table_ids_count > 0 ? join(",", var.requester_route_table_ids) : join(",", data.aws_route_tables.requester.ids)}" | ||
requester_route_table_ids_count = "${var.requester_route_table_ids_count > 0 ? var.requester_route_table_ids_count : length(data.aws_route_tables.accepter.ids)}" | ||
} | ||
accepter_route_table_ids = split(",", local.accepter_route_table_ids_join) | ||
accepter_route_table_ids_join = var.accepter_route_table_ids_count > 0 ? join(",", var.accepter_route_table_ids) : join(",", data.aws_route_tables.accepter.ids) | ||
accepter_route_table_ids_count = var.accepter_route_table_ids_count > 0 ? var.accepter_route_table_ids_count : length(data.aws_route_tables.accepter.ids) | ||
requester_route_table_ids = split(",", local.requester_route_table_ids_join) | ||
requester_route_table_ids_join = var.requester_route_table_ids_count > 0 ? join(",", var.requester_route_table_ids) : join(",", data.aws_route_tables.requester.ids) | ||
requester_route_table_ids_count = var.requester_route_table_ids_count > 0 ? var.requester_route_table_ids_count : length(data.aws_route_tables.accepter.ids) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,71 @@ | ||
resource "aws_vpc_peering_connection" "connection" { | ||
auto_accept = false | ||
peer_owner_id = "${data.aws_caller_identity.accepter.account_id}" | ||
peer_region = "${data.aws_region.accepter.name}" | ||
peer_vpc_id = "${data.aws_vpc.accepter.id}" | ||
provider = "aws.requester" | ||
tags = "${var.requester_tags}" | ||
vpc_id = "${data.aws_vpc.requester.id}" | ||
peer_owner_id = data.aws_caller_identity.accepter.account_id | ||
peer_region = data.aws_region.accepter.name | ||
peer_vpc_id = data.aws_vpc.accepter.id | ||
provider = aws.requester | ||
tags = var.requester_tags | ||
vpc_id = data.aws_vpc.requester.id | ||
} | ||
|
||
resource "aws_vpc_peering_connection_accepter" "accepter" { | ||
auto_accept = true | ||
provider = "aws.accepter" | ||
tags = "${var.accepter_tags}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.connection.id}" | ||
provider = aws.accepter | ||
tags = var.accepter_tags | ||
vpc_peering_connection_id = aws_vpc_peering_connection.connection.id | ||
} | ||
|
||
resource "aws_vpc_peering_connection_options" "accepter" { | ||
accepter = "${var.accepter_options}" | ||
count = "${length(keys(var.accepter_options)) > 0 ? 1 : 0}" | ||
provider = "aws.accepter" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.connection.id}" | ||
accepter { | ||
allow_classic_link_to_remote_vpc = lookup(var.accepter_options, "allow_classic_link_to_remote_vpc", false) | ||
allow_remote_vpc_dns_resolution = lookup(var.accepter_options, "allow_remote_vpc_dns_resolution", false) | ||
allow_vpc_to_remote_classic_link = lookup(var.accepter_options, "allow_vpc_to_remote_classic_link", false) | ||
} | ||
count = length(keys(var.accepter_options)) > 0 ? 1 : 0 | ||
provider = aws.accepter | ||
vpc_peering_connection_id = aws_vpc_peering_connection.connection.id | ||
} | ||
|
||
resource "aws_vpc_peering_connection_options" "requester" { | ||
accepter = "${var.requester_options}" | ||
count = "${length(keys(var.requester_options)) > 0 ? 1 : 0}" | ||
provider = "aws.requester" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.connection.id}" | ||
accepter { | ||
allow_classic_link_to_remote_vpc = lookup(var.requester_options, "allow_classic_link_to_remote_vpc", false) | ||
allow_remote_vpc_dns_resolution = lookup(var.requester_options, "allow_remote_vpc_dns_resolution", false) | ||
allow_vpc_to_remote_classic_link = lookup(var.requester_options, "allow_vpc_to_remote_classic_link", false) | ||
} | ||
count = length(keys(var.requester_options)) > 0 ? 1 : 0 | ||
provider = aws.requester | ||
vpc_peering_connection_id = aws_vpc_peering_connection.connection.id | ||
} | ||
|
||
resource "aws_route" "accepter_ipv4" { | ||
count = "${local.accepter_route_table_ids_count}" | ||
destination_cidr_block = "${data.aws_vpc.requester.cidr_block}" | ||
provider = "aws.accepter" | ||
route_table_id = "${local.accepter_route_table_ids[count.index]}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.connection.id}" | ||
count = local.accepter_route_table_ids_count | ||
destination_cidr_block = data.aws_vpc.requester.cidr_block | ||
provider = aws.accepter | ||
route_table_id = local.accepter_route_table_ids[count.index] | ||
vpc_peering_connection_id = aws_vpc_peering_connection.connection.id | ||
} | ||
|
||
resource "aws_route" "accepter_ipv6" { | ||
count = "${var.route_ipv6 ? local.accepter_route_table_ids_count : 0}" | ||
destination_ipv6_cidr_block = "${data.aws_vpc.requester.ipv6_cidr_block}" | ||
provider = "aws.accepter" | ||
route_table_id = "${local.accepter_route_table_ids[count.index]}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.connection.id}" | ||
count = var.route_ipv6 ? local.accepter_route_table_ids_count : 0 | ||
destination_ipv6_cidr_block = data.aws_vpc.requester.ipv6_cidr_block | ||
provider = aws.accepter | ||
route_table_id = local.accepter_route_table_ids[count.index] | ||
vpc_peering_connection_id = aws_vpc_peering_connection.connection.id | ||
} | ||
|
||
resource "aws_route" "requester_ipv4" { | ||
count = "${local.requester_route_table_ids_count}" | ||
destination_cidr_block = "${data.aws_vpc.accepter.cidr_block}" | ||
provider = "aws.requester" | ||
route_table_id = "${local.requester_route_table_ids[count.index]}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.connection.id}" | ||
count = local.requester_route_table_ids_count | ||
destination_cidr_block = data.aws_vpc.accepter.cidr_block | ||
provider = aws.requester | ||
route_table_id = local.requester_route_table_ids[count.index] | ||
vpc_peering_connection_id = aws_vpc_peering_connection.connection.id | ||
} | ||
|
||
resource "aws_route" "requester_ipv6" { | ||
count = "${var.route_ipv6 ? local.requester_route_table_ids_count : 0}" | ||
destination_ipv6_cidr_block = "${data.aws_vpc.accepter.ipv6_cidr_block}" | ||
provider = "aws.requester" | ||
route_table_id = "${local.requester_route_table_ids[count.index]}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.connection.id}" | ||
count = var.route_ipv6 ? local.requester_route_table_ids_count : 0 | ||
destination_ipv6_cidr_block = data.aws_vpc.accepter.ipv6_cidr_block | ||
provider = aws.requester | ||
route_table_id = local.requester_route_table_ids[count.index] | ||
vpc_peering_connection_id = aws_vpc_peering_connection.connection.id | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
output "accept_status" { | ||
description = "The status of the VPC Peering Connection request." | ||
value = "${aws_vpc_peering_connection.connection.accept_status}" | ||
value = aws_vpc_peering_connection.connection.accept_status | ||
} | ||
|
||
output "id" { | ||
description = "The ID of the VPC Peering Connection." | ||
value = "${aws_vpc_peering_connection.connection.id}" | ||
} | ||
value = aws_vpc_peering_connection.connection.id | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,64 @@ | ||
variable "accepter_options" { | ||
default = {} | ||
description = "An optional configuration block that allows for VPC Peering Connection options to be set for the VPC that accepts the peering connection (a maximum of one)." | ||
type = "map" | ||
type = map(string) | ||
} | ||
|
||
variable "accepter_route_table_ids" { | ||
default = [] | ||
description = "A list of route table ids within the accepter VPC to attach the peering route to. If not present all route tables in the VPC will be updated." | ||
type = "list" | ||
type = list(string) | ||
} | ||
|
||
variable "accepter_route_table_ids_count" { | ||
default = 0 | ||
description = "The number of route table ids in accepter_route_table_ids." | ||
type = "string" | ||
type = number | ||
} | ||
|
||
variable "accepter_tags" { | ||
default = {} | ||
description = "Tags to add to the accepter side resources of the connection." | ||
type = "map" | ||
type = map(string) | ||
} | ||
|
||
variable "accepter_vpc_id" { | ||
description = "The ID of the VPC with which you are creating the VPC Peering Connection." | ||
type = "string" | ||
type = string | ||
} | ||
|
||
variable "requester_options" { | ||
default = {} | ||
description = "A optional configuration block that allows for VPC Peering Connection options to be set for the VPC that requests the peering connection (a maximum of one)." | ||
type = "map" | ||
description = "A optional configuration block that allows for VPC Peering Connection options to be set for the VPC that requests the peering connection (a maximum of one)." | ||
type = map(string) | ||
} | ||
|
||
variable "requester_route_table_ids" { | ||
default = [] | ||
description = "A list of route table ids within the requester VPC to attach the peering route to. If not present all route tables in the VPC will be updated." | ||
type = "list" | ||
type = list(string) | ||
} | ||
|
||
variable "requester_route_table_ids_count" { | ||
default = 0 | ||
description = "The number of route table ids in requester_route_table_ids." | ||
type = "string" | ||
type = number | ||
} | ||
|
||
variable "requester_tags" { | ||
default = {} | ||
description = "Tags to add to the requester side resources of the connection." | ||
type = "map" | ||
type = map(string) | ||
} | ||
|
||
variable "requester_vpc_id" { | ||
description = "The ID of the requester VPC." | ||
type = "string" | ||
type = string | ||
} | ||
|
||
variable "route_ipv6" { | ||
default = false | ||
description = "Creates ipv6 routes in addition to the standard ipv4 routes" | ||
type = "string" | ||
} | ||
type = string | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |