Resource: aws_route#
Creates a routing table entry (a route) in a VPC routing table.
~> Note on route tables and routes Terraform currently provides both a standalone route resource and a aws_route_table resource with routes defined inline. At this time you cannot use a route table with inline routes in conjunction with any route resources. Doing so will cause a conflict of rule settings and will overwrite rules.
Example usage#
Basic example#
variable route_table_id {}
variable instance_id {}
resource "aws_route" "example" {
route_table_id = var.route_table_id
destination_cidr_block = "10.0.0.0/22"
instance_id = var.instance_id
}
Argument reference#
The following argument is supported:
route_table_id- (Required, Forces new resource, String) The ID of the routing table.
The following destination argument must be supplied:
destination_cidr_block- (Required, Forces new resource, String) The destination CIDR block.
One of the following target arguments must be supplied:
gateway_id- (Optional, Editable, String) The ID of the internet gateway.network_interface_id- (Optional, Editable, String) The ID of the network interface.transit_gateway_id- (Optional, Editable, String) The ID of the transit gateway.
This argument is deprecated and should not be used:
instance_id- (Optional, Editable, String) The ID of the instance. Use thenetwork_interface_idargument instead.
Attribute reference#
Supported attributes#
In addition to all arguments above, the following attributes are exported:
~> Note Only the arguments that are configured (one of the above) will be exported as an attribute once the resource is created.
id- (String) The route identifier computed from the routing table identifier and route destination.instance_owner_id- (String) The ID of the project that owns the instance.origin- (String) Describes how the route was created - byCreateRouteTable,CreateRouteorEnableVgwRoutePropagation.state- (String) The state of the route -activeorblackhole.
Unsupported attributes#
~> Note These attributes may be present in the terraform.tfstate file, but they have preset values and cannot be specified in configuration files.
The following attributes are not currently supported:
carrier_gateway_id, core_network_arn, destination_ipv6_cidr_block, destination_prefix_list_id, egress_only_gateway_id, local_gateway_id, nat_gateway_id, vpc_endpoint_id, vpc_peering_connection_id.
Timeouts#
The timeouts block allows you to specify timeouts for certain actions:
create- (Default5 minutes) Used for route creation.update- (Default2 minutes) Used for route creation.delete- (Default5 minutes) Used for route deletion.
Import#
Individual routes can be imported using ROUTETABLEID_DESTINATION.
For example, import a route in route table rtb-12345678 with an IPv4 destination CIDR of 10.1.0.0/16 like this:
$ terraform import aws_route.my_route rtb-12345678_10.1.0.0/16