1
votes

My company uses AWS as a cloud provider and Terraform to do our Infrastructure as code piece. I need to make a change to the way our traffic routes in AWS. We currently have 1 NAT gateway. So if the AZ that this live sin went down we'd lose external connectivity from our instances that live on our private subnets.

I've created 2 extra NAT GW's. One in each AZ. I have done all of this through Terraform ok but I've run into a stumbling block when it comes to the routing.

I've created this type of setup, where you have a routing table for both private and public subnets in each AZ

NAT GW Architecture and routing

We have a Direct Connect and use BGP to advertise our Datacentre networks to AWS. I can't seem to figure out how to enable route propagation on the private subnet route tables so that our on-prem networks get populated in these route tables.

resource "aws_route_table" "private-subnet-a-routes" {
    vpc_id = "${aws_vpc.foo.id}"
    propogating_vgws "${aws_vgw.foo.id}" 

I have tried that but get the below error

  • resource 'aws_route_table.private-subnet-a-routes' config: unknown resource 'aws_vgw.foo' referenced in variable aws_vgw.foo.id

Does anyone know how to set routes to be propagated on a route table from the main VGW in your VPC?

Thanks in advance

Chris

1

1 Answers

0
votes

Not sure that answers your question but might give you some ideas:

resource "aws_route" "nat" {
    count = "${var.num_availability_zones}"
    route_table_id = "${element(aws_route_table.private.*.id, count.index)}"
    destination_cidr_block = "0.0.0.0/0"
    nat_gateway_id = "${element(aws_nat_gateway.nat.*.id, count.index)}"

    depends_on = ["aws_internet_gateway.main", "aws_route_table.private"]
}

https://www.terraform.io/docs/providers/aws/d/route.html