I'm unable to fetch the default route table id associated with the private subnet.
I get the following error. This seems to be reported on github. I'm not sure how to get the route table ID for private subnets.
Your query returned no results. Please change your search criteria and try again.
One workaround I tried was to produce a list of VPC subnets using the aws_subnet_ids Data Source, and then discover all route table ids by using the aws_route_table Data Source with count and subnet_id as a parameter for each iteration, but this does not always work, because if there are one or more subnets that are (non-explictly) associated with the Main route table, TF will error as follows:
data.tf:
data "aws_route_table" "private_subnet_RT" { depends_on = [ aws_subnet.private_subnet ] count = length(var.availability_zones) # subnet_id = "${element(aws_subnet.private_subnet.*.id, count.index)}" subnet_id = "subnet-01bae78f452ca0000" } subnets.tf
# Create Private Subnets resource "aws_subnet" "private_subnet" { count = length(var.availability_zones) vpc_id = var.vpc_id cidr_block = var.private_subnet_cidr[count.index] availability_zone = "${element(var.availability_zones, count.index)}" tags = merge({ Name = "Private_subnet_${count.index} - ${var.environment}" }, var.private_subnet_tags) } Though the route table doesn't show that its associated with a subnet..

