-
Notifications
You must be signed in to change notification settings - Fork 5
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 #3 from confusdcodr/t12
Upgrade to terraform 0.12.x
- Loading branch information
Showing
20 changed files
with
320 additions
and
132 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,6 +1,7 @@ | ||
[bumpversion] | ||
current_version = 0.0.0 | ||
current_version = 1.0.0 | ||
commit = True | ||
message = Bumps version to {new_version} | ||
tag = False | ||
tag_name = {new_version} | ||
|
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
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
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
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
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
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,77 +1,70 @@ | ||
provider "aws" {} | ||
provider "aws" { | ||
} | ||
|
||
provider "aws" { | ||
alias = "peer" | ||
} | ||
|
||
data "aws_vpc" "peer" { | ||
count = "${var.create_peering_connection ? 1 : 0}" | ||
count = var.create_peering_connection ? 1 : 0 | ||
|
||
provider = "aws.peer" | ||
provider = aws.peer | ||
|
||
id = "${var.peer_vpc_id}" | ||
id = var.peer_vpc_id | ||
} | ||
|
||
resource "aws_vpc_peering_connection" "this" { | ||
count = "${var.create_peering_connection ? 1 : 0}" | ||
|
||
peer_owner_id = "${var.peer_owner_id}" | ||
peer_vpc_id = "${var.peer_vpc_id}" | ||
vpc_id = "${var.vpc_id}" | ||
tags = "${merge(var.tags, map("Name", "${var.name}-${var.vpc_cidr}<->${var.peer_alias}-${data.aws_vpc.peer.cidr_block}"))}" | ||
count = var.create_peering_connection ? 1 : 0 | ||
|
||
peer_owner_id = var.peer_owner_id | ||
peer_vpc_id = var.peer_vpc_id | ||
vpc_id = var.vpc_id | ||
tags = merge( | ||
var.tags, | ||
{ | ||
"Name" = "${format("%v", var.name)}-${format("%v", var.vpc_cidr)}<->${format("%v", var.peer_alias)}-${data.aws_vpc.peer[0].cidr_block}" | ||
}, | ||
) | ||
} | ||
|
||
resource "aws_vpc_peering_connection_accepter" "this" { | ||
count = "${var.create_peering_connection ? 1 : 0}" | ||
count = var.create_peering_connection ? 1 : 0 | ||
|
||
provider = "aws.peer" | ||
provider = aws.peer | ||
|
||
vpc_peering_connection_id = "${aws_vpc_peering_connection.this.id}" | ||
vpc_peering_connection_id = aws_vpc_peering_connection.this[0].id | ||
auto_accept = true | ||
|
||
tags { | ||
Name = "${var.peer_alias}-${data.aws_vpc.peer.cidr_block}<->${var.name}-${var.vpc_cidr}" | ||
tags = { | ||
Name = "${format("%v", var.peer_alias)}-${data.aws_vpc.peer[0].cidr_block}<->${format("%v", var.name)}-${format("%v", var.vpc_cidr)}" | ||
} | ||
} | ||
|
||
resource "aws_route" "public" { | ||
// Must pin count to avoid error "value of 'count' cannot be computed" | ||
// See: | ||
// * <https://docs.cloudposse.com/troubleshooting/terraform-value-of-count-cannot-be-computed/> | ||
// * <https://github.com/hashicorp/terraform/issues/12570> | ||
// Proper value once #12570 has some reasonable resolution: | ||
// count = "${var.create_peering_connection ? length(var.public_route_tables) : 0}" | ||
count = "${var.create_peering_connection ? 1 : 0}" | ||
|
||
route_table_id = "${var.public_route_tables[count.index]}" | ||
destination_cidr_block = "${data.aws_vpc.peer.cidr_block}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.this.id}" | ||
count = var.create_peering_connection ? length(var.public_route_tables) : 0 | ||
|
||
route_table_id = var.public_route_tables[count.index] | ||
destination_cidr_block = data.aws_vpc.peer[0].cidr_block | ||
vpc_peering_connection_id = aws_vpc_peering_connection.this[0].id | ||
} | ||
|
||
resource "aws_route" "private" { | ||
// Must pin count to avoid error "value of 'count' cannot be computed" | ||
// See: | ||
// * <https://docs.cloudposse.com/troubleshooting/terraform-value-of-count-cannot-be-computed/> | ||
// * <https://github.com/hashicorp/terraform/issues/12570> | ||
// Proper value once #12570 has some reasonable resolution: | ||
// count = "${var.create_peering_connection ? length(var.private_route_tables) : 0}" | ||
count = "${var.create_peering_connection ? 1 : 0}" | ||
|
||
route_table_id = "${var.private_route_tables[count.index]}" | ||
destination_cidr_block = "${data.aws_vpc.peer.cidr_block}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection.this.id}" | ||
count = var.create_peering_connection ? length(var.private_route_tables) : 0 | ||
|
||
route_table_id = var.private_route_tables[count.index] | ||
destination_cidr_block = data.aws_vpc.peer[0].cidr_block | ||
vpc_peering_connection_id = aws_vpc_peering_connection.this[0].id | ||
} | ||
|
||
resource "aws_route" "peer" { | ||
// No need to pin this one, since we pass this value in | ||
// I.e. We are not _creating_ the route tables in the same state... | ||
count = "${var.create_peering_connection ? length(var.peer_route_tables) : 0}" | ||
count = var.create_peering_connection ? length(var.peer_route_tables) : 0 | ||
|
||
provider = "aws.peer" | ||
provider = aws.peer | ||
|
||
route_table_id = "${var.peer_route_tables[count.index]}" | ||
destination_cidr_block = "${var.vpc_cidr}" | ||
vpc_peering_connection_id = "${aws_vpc_peering_connection_accepter.this.id}" | ||
route_table_id = var.peer_route_tables[count.index] | ||
destination_cidr_block = var.vpc_cidr | ||
vpc_peering_connection_id = aws_vpc_peering_connection_accepter.this[0].id | ||
|
||
depends_on = ["aws_vpc_peering_connection_accepter.this"] | ||
depends_on = [aws_vpc_peering_connection_accepter.this] | ||
} | ||
|
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 "vpc_peering_connection_id" { | ||
description = "The ID of the VPC Peering Connection" | ||
value = "${join("", aws_vpc_peering_connection_accepter.this.*.id)}" | ||
value = join("", aws_vpc_peering_connection_accepter.this.*.id) | ||
} | ||
|
||
output "vpc_peering_connection_status" { | ||
description = "The status of the VPC Peering Connection request" | ||
value = "${join("", aws_vpc_peering_connection_accepter.this.*.accept_status)}" | ||
value = join("", aws_vpc_peering_connection_accepter.this.*.accept_status) | ||
} | ||
|
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,48 @@ | ||
provider aws { | ||
region = "us-east-1" | ||
} | ||
|
||
data "aws_caller_identity" "current" {} | ||
|
||
resource "random_string" "this" { | ||
length = 6 | ||
number = false | ||
special = false | ||
upper = false | ||
} | ||
|
||
module "vpc_pcx_requester" { | ||
source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v2.15.0" | ||
|
||
providers = { | ||
aws = aws | ||
} | ||
|
||
name = "tardigrade-pcx-requester-${random_string.this.result}" | ||
cidr = "10.0.0.0/16" | ||
} | ||
|
||
module "vpc_pcx_requestee" { | ||
source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v2.15.0" | ||
|
||
providers = { | ||
aws = aws | ||
} | ||
|
||
name = "tardigrade-pcx-requestee-${random_string.this.result}" | ||
cidr = "10.1.0.0/16" | ||
} | ||
|
||
module "create_pcx" { | ||
source = "../../" | ||
providers = { | ||
aws = aws | ||
aws.peer = aws | ||
} | ||
|
||
create_peering_connection = true | ||
name = "tardigrade-pcx-${random_string.this.result}" | ||
vpc_id = module.vpc_pcx_requester.vpc_id | ||
peer_owner_id = data.aws_caller_identity.current.account_id | ||
peer_vpc_id = module.vpc_pcx_requestee.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
terraform { | ||
required_version = ">= 0.12" | ||
} |
This file was deleted.
Oops, something went wrong.
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,53 @@ | ||
provider aws { | ||
region = "us-east-1" | ||
} | ||
|
||
data "aws_caller_identity" "current" {} | ||
|
||
resource "random_string" "this" { | ||
length = 6 | ||
number = false | ||
special = false | ||
upper = false | ||
} | ||
|
||
module "vpc_pcx_requester" { | ||
source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v2.15.0" | ||
|
||
providers = { | ||
aws = aws | ||
} | ||
|
||
name = "tardigrade-pcx-requester-${random_string.this.result}" | ||
cidr = "10.0.0.0/16" | ||
azs = ["us-east-1a", "us-east-1b", "us-east-1c"] | ||
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] | ||
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] | ||
} | ||
|
||
module "vpc_pcx_requestee" { | ||
source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v2.15.0" | ||
|
||
providers = { | ||
aws = aws | ||
} | ||
|
||
name = "tardigrade-pcx-requestee-${random_string.this.result}" | ||
cidr = "10.1.0.0/16" | ||
} | ||
|
||
module "generated_route_tables" { | ||
source = "../../" | ||
providers = { | ||
aws = aws | ||
aws.peer = aws | ||
} | ||
|
||
create_peering_connection = true | ||
name = "tardigrade-pcx-${random_string.this.result}" | ||
vpc_id = module.vpc_pcx_requester.vpc_id | ||
peer_owner_id = data.aws_caller_identity.current.account_id | ||
peer_vpc_id = module.vpc_pcx_requestee.vpc_id | ||
public_route_tables = module.vpc_pcx_requester.public_route_table_ids | ||
private_route_tables = module.vpc_pcx_requester.private_route_table_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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
terraform { | ||
required_version = ">= 0.12" | ||
} |
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,11 @@ | ||
module terraform-aws-tardigrade-pcx/tests | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/gruntwork-io/terratest v0.19.0 | ||
github.com/magiconair/properties v1.8.1 // indirect | ||
github.com/stretchr/testify v1.4.0 // indirect | ||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 // indirect | ||
golang.org/x/net v0.0.0-20190918130420-a8b05e9114ab // indirect | ||
) |
Oops, something went wrong.