Data Source: aws_route_table

aws_route_table provides details about a specific Route Table.

This resource can prove useful when a module accepts a Subnet id as an input variable and needs to, for example, add a route in the Route Table.

Example Usage

The following example shows how one might accept a Route Table id as a variable and use this data source to obtain the data necessary to create a route.

variable "subnet_id" {}

data "aws_route_table" "selected" {
  subnet_id = "${var.subnet_id}"
}

resource "aws_route" "route" {
  route_table_id            = "${data.aws_route_table.selected.id}"
  destination_cidr_block    = "10.0.1.0/22"
  vpc_peering_connection_id = "pcx-45ff3dc1"
}

Argument Reference

The arguments of this data source act as filters for querying the available Route Table in the current region. The given filters must match exactly one Route Table whose data will be exported as attributes.

  • filter - (Optional) Custom filter block as described below.

  • route_table_id - (Optional) The id of the specific Route Table to retrieve.

  • tags - (Optional) A mapping of tags, each pair of which must exactly match a pair on the desired Route Table.

  • vpc_id - (Optional) The id of the VPC that the desired Route Table belongs to.

  • subnet_id - (Optional) The id of a Subnet which is connected to the Route Table (not be exported if not given in parameter).

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

  • name - (Required) The name of the field to filter by, as defined by the underlying AWS API.

  • values - (Required) Set of values that are accepted for the given field. A Route Table will be selected if any one of the given values matches.

Attributes Reference

All of the argument attributes except filter and subnet_id blocks are also exported as result attributes. This data source will complete the data by populating any fields that are not included in the configuration with the data for the selected Route Table.

routes are also exported with the following attributes, when there are relevants: Each route supports the following:

associations are also exported with the following attributes:

© 2018 HashiCorp
Licensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/aws/d/route_table.html