Currently, I have an outputs with AWS subnet IDs Like this
subnets = {
+ GPS = [
+ "subnet-0b8d3d38456431efd",
+ "subnet-0678f4a68a7517d15",
+ "subnet-030f9b726908f6fa1",
]
+ admin = [
+ "subnet-073346e287fd0070c",
+ "subnet-05865fb67386d2fb9",
+ "subnet-04b27673caad2e651",
]
+ data = [
+ "subnet-0aeb9d129d278f363",
+ "subnet-0fdac331bf0c1221e",
+ "subnet-0c44442616e51b459",
]
+ private = [
+ "subnet-08a6934c70fde452c",
+ "subnet-04abb86d569d30bbc",
+ "subnet-0fcc9113742ffb4fe",
]
+ public = [
+ "subnet-02862107c9307838b",
+ "subnet-0c8154cc71a9566c9",
+ "subnet-09ce42aa351e803c3",
]
}
Since in AWS, each subnet has a corresponding route table ID. I would like to get it’s corresponding route table ID and store it in a different list like for example:
route_tables = {
GPS = ["rt-xxx", "rt-xxx", "rt-xx"],
data = ["rt-xxx", "rt-xxx", "rt-xx"],
admin = ["rt-xxx", "rt-xxx", rt-xx"],
public = ["rt-xxx", "rt-xxx", "rt-xx"],
private = ["rt-xxx", "rt-xxx", "rt-xx"]
}
I would like to know if that is possible by using the data resource for aws_route_table
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route_table#subnet_id