Created
April 14, 2016 01:18
-
-
Save charity/2ceebb7e86318a9477178f454dc2c733 to your computer and use it in GitHub Desktop.
Revisions
-
charity created this gist
Apr 14, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # file name: terraform/env-staging/peering.tf # No peering / direct connectivity between staging and prod, for safety. resource "terraform_remote_state" "dev_state" { backend = "s3" config { bucket = "${var.tf_s3_bucket}" region = "${var.region}" key = "${var.dev_state_file}" } } # lookup and reuse the same peering connection # add a route to the public subnet resource "aws_route" "staging_to_dev_route" { route_table_id = "${module.staging_vpc.public_route_table_id}" # depends_on = ["${module.dev_vpc.public_route_table_id}"] destination_cidr_block = "${terraform_remote_state.dev_state.output.dev_cidr_block}" vpc_peering_connection_id = "${terraform_remote_state.dev_state.output.aws_vpc_peering_dev_staging}" } # add the route to each of the private route tables. routing to the /16 is fineeeeee resource "aws_route" "dev_to_staging_int_route" { count = "${length(split(",", var.private_ranges))}" route_table_id = "${element(split(",", module.staging_vpc.private_route_table_id), count.index)}" destination_cidr_block = "${terraform_remote_state.dev_state.output.dev_cidr_block}" vpc_peering_connection_id = "${terraform_remote_state.dev_state.output.aws_vpc_peering_dev_staging}" }