terraform-community-modules / tf_aws_vpc

[DEPRECATED] Use https://github.com/terraform-aws-modules/terraform-aws-vpc
Other
210 stars 203 forks source link

Output private route table id #7

Closed StuartHarris closed 7 years ago

StuartHarris commented 8 years ago

When setting up a NAT instance, the private route table needs an extra route to direct outbound traffic to the NAT instance. By outputting the route table id, you can add the route later like this:

resource "aws_route" "outbound_internet" {
  route_table_id = "${module.vpc.private_route_table_id}"
  destination_cidr_block = "0.0.0.0/0"
  // TODO: but we've got 2 NAT instances - one in each AZ ...
  instance_id = "${element(split(",", module.nat.instance_ids), 0)}"
}
antonbabenko commented 8 years ago

Make sense, though I am personally not using this module, but rather combine networking from separate blocks (vpc - one module; private subnets with NAT - 2 modules (one module for subnet+route_table; second for running NAT instances); internet gateway - one module; public subnet - 1 module which is dependent on internet gateway module.

I also think that this change should be compatible with multiple route_tables, as there is already support for multiple private subnets in outputs - value = "${join(",", aws_route_table.private.*.id)}".

willejs commented 8 years ago

@StuartHarris Could you add the public route table too?

zot24 commented 7 years ago

I think this PR can be closed now, isn't it? as per this have been implemented already https://github.com/terraform-community-modules/tf_aws_vpc/blob/master/outputs.tf#L18