-
-
Save cyakimov/59d3fbd21072bcadb1d41120cdcbcb2b to your computer and use it in GitHub Desktop.
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
# 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}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment