Skip to content

Instantly share code, notes, and snippets.

@trung
Last active July 14, 2017 15:12
Show Gist options
  • Save trung/9b965f618b0de14dc7d83e41698b3a06 to your computer and use it in GitHub Desktop.
Save trung/9b965f618b0de14dc7d83e41698b3a06 to your computer and use it in GitHub Desktop.
How to retrieve default route table id for a VPC
variable "vpcId" {
default = "vpc-5f98eb36"
}
data "aws_route_table" "all" {
vpc_id = "${var.vpcId}"
filter {
name = "association.main"
values = ["true"]
}
}
output "defaultRouteTableId" {
value = "${data.aws_route_table.all.associations.0.route_table_id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment