What specific syntax must be used in order for the Terraform aws_route_table
data source below to successfully return the route table that is NOT designated the main route table in the VPC?
data "aws_route_table" "rt" {
vpc_id = var.vpcId
filter {
name = "association.main"
values = [false]
}
}
There is only one non-main route table in the VPC. Therefore, filtering for main=false
should identify it if the filter syntax is correct.
The error currently produced by the above code is:
Error: Your query returned no results. Please change your search criteria and try again
I did some tests on my own, and here are some of my findings. aws_route_tables rather then aws_route_table should be used to return multiple RTs:
However, there are few things to know about:
So basically, the usefulness of the above filter highly depends on how your VPC and RTs are organized.
Below is AWS CLI that I also used to double check some of these findings: