2014-07-23 23:26:47 +02:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_route_table"
|
|
|
|
sidebar_current: "docs-aws-resource-route-table|"
|
2014-10-22 05:21:56 +02:00
|
|
|
description: |-
|
|
|
|
Provides a resource to create a VPC routing table.
|
2014-07-23 23:26:47 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# aws\_route\_table
|
|
|
|
|
|
|
|
Provides a resource to create a VPC routing table.
|
|
|
|
|
2015-10-15 23:55:47 +02:00
|
|
|
~> **NOTE on Route Tables and Routes:** Terraform currently
|
|
|
|
provides both a standalone [Route resource](route.html) and a Route Table resource with routes
|
|
|
|
defined in-line. At this time you cannot use a Route Table with in-line routes
|
|
|
|
in conjunction with any Route resources. Doing so will cause
|
|
|
|
a conflict of rule settings and will overwrite rules.
|
|
|
|
|
2017-05-18 23:12:11 +02:00
|
|
|
~> **NOTE on `gateway_id` and `nat_gateway_id`:** The AWS API is very foregiving with these two
|
|
|
|
attributes and the `aws_route_table` resource can be created with a NAT ID specified as a Gateway ID attribute.
|
|
|
|
This _will_ lead to a permanent diff between your configuration and statefile, as the API returns the correct
|
|
|
|
parameters in the returned route table. If you're experiencing constant diffs in your `aws_route_table` resources,
|
|
|
|
the first thing to check is whether or not you're specifying a NAT ID instead of a Gateway ID, or vice-versa.
|
|
|
|
|
2014-12-10 19:33:13 +01:00
|
|
|
## Example usage with tags:
|
2014-07-23 23:26:47 +02:00
|
|
|
|
2017-04-17 12:17:54 +02:00
|
|
|
```hcl
|
2014-07-23 23:26:47 +02:00
|
|
|
resource "aws_route_table" "r" {
|
2017-02-18 23:48:50 +01:00
|
|
|
vpc_id = "${aws_vpc.default.id}"
|
|
|
|
|
|
|
|
route {
|
|
|
|
cidr_block = "10.0.1.0/24"
|
|
|
|
gateway_id = "${aws_internet_gateway.main.id}"
|
|
|
|
}
|
|
|
|
|
2017-03-14 11:38:25 +01:00
|
|
|
route {
|
|
|
|
ipv6_cidr_block = "::/0"
|
|
|
|
egress_only_gateway_id = "${aws_egress_only_internet_gateway.foo.id}"
|
|
|
|
}
|
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
tags {
|
|
|
|
Name = "main"
|
|
|
|
}
|
2014-07-23 23:26:47 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2017-05-28 07:37:44 +02:00
|
|
|
* `vpc_id` - (Required) The VPC ID.
|
2015-01-14 18:28:25 +01:00
|
|
|
* `route` - (Optional) A list of route objects. Their keys are documented below.
|
2014-12-10 19:33:13 +01:00
|
|
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
2015-05-12 18:13:02 +02:00
|
|
|
* `propagating_vgws` - (Optional) A list of virtual gateways for propagation.
|
2014-07-23 23:26:47 +02:00
|
|
|
|
|
|
|
Each route supports the following:
|
|
|
|
|
2017-03-14 11:38:25 +01:00
|
|
|
* `cidr_block` - (Optional) The CIDR block of the route.
|
|
|
|
* `ipv6_cidr_block` - Optional) The Ipv6 CIDR block of the route
|
|
|
|
* `egress_only_gateway_id` - (Optional) The Egress Only Internet Gateway ID.
|
2014-07-23 23:26:47 +02:00
|
|
|
* `gateway_id` - (Optional) The Internet Gateway ID.
|
2015-12-18 08:20:13 +01:00
|
|
|
* `nat_gateway_id` - (Optional) The NAT Gateway ID.
|
2014-07-23 23:26:47 +02:00
|
|
|
* `instance_id` - (Optional) The EC2 instance ID.
|
2015-02-10 17:50:29 +01:00
|
|
|
* `vpc_peering_connection_id` - (Optional) The VPC Peering ID.
|
2015-04-17 19:18:46 +02:00
|
|
|
* `network_interface_id` - (Optional) The ID of the elastic network interface (eni) to use.
|
2014-07-23 23:26:47 +02:00
|
|
|
|
2015-12-18 08:20:13 +01:00
|
|
|
Each route must contain either a `gateway_id`, an `instance_id`, a `nat_gateway_id`, a
|
|
|
|
`vpc_peering_connection_id` or a `network_interface_id`. Note that the default route, mapping
|
|
|
|
the VPC's CIDR block to "local", is created implicitly and cannot be specified.
|
2014-08-22 02:08:51 +02:00
|
|
|
|
2014-07-23 23:26:47 +02:00
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
2015-06-24 05:44:02 +02:00
|
|
|
~> **NOTE:** Only the target that is entered is exported as a readable
|
|
|
|
attribute once the route resource is created.
|
2014-07-23 23:26:47 +02:00
|
|
|
|
|
|
|
* `id` - The ID of the routing table
|
2016-07-21 00:28:59 +02:00
|
|
|
|
|
|
|
## Import
|
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
Route Tables can be imported using the `route table id`, e.g.
|
2016-07-21 00:28:59 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import aws_route_table.public_rt rtb-22574640
|
2017-05-18 23:12:11 +02:00
|
|
|
```
|