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.

The following arguments are optional:

filter

Complex filters can be expressed using one or more filter blocks.

The following arguments are required:

Attribute Reference

This data source exports the following attributes in addition to the arguments above:

routes

When relevant, routes are also exported with the following attributes:

For destinations:

For targets:

associations

Associations are also exported with the following attributes:

Timeouts

Configuration options: