Provides a resource to create a VPC routing table.
NOTE on Route Tables and Routes: Terraform currently provides both a standalone Route resource 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.
NOTE on
gateway_idandnat_gateway_id: The AWS API is very forgiving with these two attributes and theaws_route_tableresource 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 youraws_route_tableresources, the first thing to check is whether or not you're specifying a NAT ID instead of a Gateway ID, or vice-versa.
NOTE on
propagating_vgwsand theaws_vpn_gateway_route_propagationresource: If thepropagating_vgwsargument is present, it's not supported to also define route propagations usingaws_vpn_gateway_route_propagation, since this resource will delete any propagating gateways not explicitly listed inpropagating_vgws. Omit this argument when defining route propagation using the separate resource.
resource "aws_route_table" "r" {
vpc_id = "${aws_vpc.default.id}"
route {
cidr_block = "10.0.1.0/24"
gateway_id = "${aws_internet_gateway.main.id}"
}
route {
ipv6_cidr_block = "::/0"
egress_only_gateway_id = "${aws_egress_only_internet_gateway.foo.id}"
}
tags {
Name = "main"
}
}
The following arguments are supported:
vpc_id - (Required) The VPC ID. route - (Optional) A list of route objects. Their keys are documented below. tags - (Optional) A mapping of tags to assign to the resource. propagating_vgws - (Optional) A list of virtual gateways for propagation. Each route supports the following:
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. gateway_id - (Optional) The Internet Gateway ID. nat_gateway_id - (Optional) The NAT Gateway ID. instance_id - (Optional) The EC2 instance ID. vpc_peering_connection_id - (Optional) The VPC Peering ID. network_interface_id - (Optional) The ID of the elastic network interface (eni) to use. 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.
In addition to all arguments above, the following attributes are exported: ~> NOTE: Only the target that is entered is exported as a readable attribute once the route resource is created.
id - The ID of the routing table Route Tables can be imported using the route table id, e.g.
$ terraform import aws_route_table.public_rt rtb-22574640
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/aws/r/route_table.html