2016-11-22 22:16:23 +01:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_route_table"
|
|
|
|
sidebar_current: "docs-aws-datasource-route-table"
|
|
|
|
description: |-
|
|
|
|
Provides details about a specific Route Table
|
|
|
|
---
|
|
|
|
|
|
|
|
# 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
|
2017-02-18 23:48:50 +01:00
|
|
|
an input variable and needs to, for example, add a route in
|
2016-11-22 22:16:23 +01:00
|
|
|
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.
|
|
|
|
|
2017-04-07 17:54:28 +02:00
|
|
|
```hcl
|
2016-11-22 22:16:23 +01:00
|
|
|
variable "subnet_id" {}
|
|
|
|
|
|
|
|
data "aws_route_table" "selected" {
|
|
|
|
subnet_id = "${var.subnet_id}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_route" "route" {
|
2017-02-18 23:48:50 +01:00
|
|
|
route_table_id = "${data.aws_route_table.selected.id}"
|
|
|
|
destination_cidr_block = "10.0.1.0/22"
|
2016-11-22 22:16:23 +01:00
|
|
|
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.
|
|
|
|
|
2017-01-11 19:22:29 +01:00
|
|
|
* `route_table_id` - (Optional) The id of the specific Route Table to retrieve.
|
2016-11-22 22:16:23 +01:00
|
|
|
|
|
|
|
* `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
|
2017-01-19 04:22:01 +01:00
|
|
|
[the underlying AWS API](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRouteTables.html).
|
2016-11-22 22:16:23 +01:00
|
|
|
|
|
|
|
* `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:
|
|
|
|
|
|
|
|
* `cidr_block` - The CIDR block of the route.
|
2017-03-14 11:38:25 +01:00
|
|
|
* `ipv6_cidr_block` - The IPv6 CIDR block of the route.
|
|
|
|
* `egress_only_gateway_id` - The ID of the Egress Only Internet Gateway.
|
2016-11-22 22:16:23 +01:00
|
|
|
* `gateway_id` - The Internet Gateway ID.
|
|
|
|
* `nat_gateway_id` - The NAT Gateway ID.
|
|
|
|
* `instance_id` - The EC2 instance ID.
|
|
|
|
* `vpc_peering_connection_id` - The VPC Peering ID.
|
|
|
|
* `network_interface_id` - The ID of the elastic network interface (eni) to use.
|
|
|
|
|
|
|
|
|
|
|
|
`associations` are also exported with the following attributes:
|
|
|
|
|
|
|
|
* `route_table_association_id` - The Association ID .
|
|
|
|
* `route_table_id` - The Route Table ID.
|
|
|
|
* `subnet_id` - The Subnet ID.
|
|
|
|
* `main` - If the Association due to the Main Route Table.
|