Skip to main content
VPC Modules 0.28.1Last updated in version 0.27.0

Route Module

View Source Release Notes

This Terraform module creates a route resource. A route is a rule that specifies where network traffic is directed. This is often utilized in more advanced network topology configurations. A route in AWS is commonly utilized to send traffic to a transit gateway, a local gateway, a VPN gateway, or a EC2 instance. Some common use cases of when an organization might leverage one or more routes:

  • To route traffic to a transit gateway for multiple AWS accounts
  • To route traffic to a Direct Connect circuit via a transit gateway
  • To route traffic to a SDWAN appliance
  • To route traffic to a firewall appliance
  • To route traffic over a VPN tunnel

[!IMPORTANT] This module may require additional modules or configuration. Other modules, such as the transit-gateway-route module, may be required to complete the route configuration. This module is intended to be used as a building block for more complex network topologies.

Usage

For usage examples, check out the examples folder.

What is a route?

A route is a path to a specific destination. A route table contains a set of rules, called routes, that are used to determine where network traffic is directed. Each subnet in your VPC must be associated with a route table; the table controls the routing for the subnet. A route table can also contain routes to other route tables.

Routes can be either dynamic or static. Dynamic routes are learned by the route table from a routing protocol. Static routes are manually added to a route table. The route table then uses the most specific route that matches the traffic to determine how to route the traffic. Where possible, it's best to utilize dynamic routes. However, static routes are often used to route traffic between different types of environments.

Requirements

NameVersion
terraform>= 1.0.0
aws>= 4.5.0

Providers

NameVersion
aws>= 4.5.0

Modules

No modules.

Resources

NameType
aws_route.thisresource

Inputs

NameDescriptionTypeDefaultRequired
carrier_gateway_idThe ID of the carrier gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
core_network_arnThe ARN of the core network used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
destination_cidr_blockThe IPv4 CIDR address block used for the destination match. Routing decisions are based on the most specific match.stringnullno
destination_ipv6_cidr_blockThe IPv6 CIDR address block used for the destination match. Routing decisions are based on the most specific match.stringnullno
destination_prefix_list_idThe ID of a prefix list used for the destination match.stringnullno
egress_only_gateway_idThe ID of the egress-only internet gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
gateway_idThe ID of the internet gateway or virtual private gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
local_gateway_idThe ID of the Outpust local gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
nat_gateway_idThe ID of the NAT gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
network_interface_idThe ID of the EC2 network interface used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
route_table_idsList of route table IDs to associate with the routelist(any)n/ayes
transit_gateway_idThe ID of the transit gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
vpc_endpoint_idThe ID of the VPC endpoint used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno
vpc_peering_connection_idThe ID of the VPC peering connection used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.stringnullno

Outputs

NameDescription
idsA map of IDs of the route resources.
statesA map of states of the route resources.

Sample Usage

main.tf

# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S ROUTE MODULE
# ------------------------------------------------------------------------------------------------------

module "route" {

source = "git::git@github.com:gruntwork-io/terraform-aws-vpc.git//modules/route?ref=v0.28.1"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------

# List of route table IDs to associate with the route
route_table_ids = <list(any)>

# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------

# The ID of the carrier gateway used for the destination match. Traffic will
# be routed to this ID. If this is set, no other destination ID or ARN can be
# set.
carrier_gateway_id = null

# The ARN of the core network used for the destination match. Traffic will be
# routed to this ID. If this is set, no other destination ID or ARN can be
# set.
core_network_arn = null

# The IPv4 CIDR address block used for the destination match. Routing
# decisions are based on the most specific match.
destination_cidr_block = null

# The IPv6 CIDR address block used for the destination match. Routing
# decisions are based on the most specific match.
destination_ipv6_cidr_block = null

# The ID of a prefix list used for the destination match.
destination_prefix_list_id = null

# The ID of the egress-only internet gateway used for the destination match.
# Traffic will be routed to this ID. If this is set, no other destination ID
# or ARN can be set.
egress_only_gateway_id = null

# The ID of the internet gateway or virtual private gateway used for the
# destination match. Traffic will be routed to this ID. If this is set, no
# other destination ID or ARN can be set.
gateway_id = null

# The ID of the Outpust local gateway used for the destination match. Traffic
# will be routed to this ID. If this is set, no other destination ID or ARN
# can be set.
local_gateway_id = null

# The ID of the NAT gateway used for the destination match. Traffic will be
# routed to this ID. If this is set, no other destination ID or ARN can be
# set.
nat_gateway_id = null

# The ID of the EC2 network interface used for the destination match. Traffic
# will be routed to this ID. If this is set, no other destination ID or ARN
# can be set.
network_interface_id = null

# The ID of the transit gateway used for the destination match. Traffic will
# be routed to this ID. If this is set, no other destination ID or ARN can be
# set.
transit_gateway_id = null

# The ID of the VPC endpoint used for the destination match. Traffic will be
# routed to this ID. If this is set, no other destination ID or ARN can be
# set.
vpc_endpoint_id = null

# The ID of the VPC peering connection used for the destination match. Traffic
# will be routed to this ID. If this is set, no other destination ID or ARN
# can be set.
vpc_peering_connection_id = null

}


Reference

Required

route_table_idslist(any)required

List of route table IDs to associate with the route

Any types represent complex values of variable type. For details, please consult `variables.tf` in the source repo.

Optional

carrier_gateway_idstringoptional

The ID of the carrier gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null
core_network_arnstringoptional

The ARN of the core network used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null

The IPv4 CIDR address block used for the destination match. Routing decisions are based on the most specific match.

null

The IPv6 CIDR address block used for the destination match. Routing decisions are based on the most specific match.

null

The ID of a prefix list used for the destination match.

null

The ID of the egress-only internet gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null
gateway_idstringoptional

The ID of the internet gateway or virtual private gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null
local_gateway_idstringoptional

The ID of the Outpust local gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null
nat_gateway_idstringoptional

The ID of the NAT gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null
network_interface_idstringoptional

The ID of the EC2 network interface used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null
transit_gateway_idstringoptional

The ID of the transit gateway used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null
vpc_endpoint_idstringoptional

The ID of the VPC endpoint used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null

The ID of the VPC peering connection used for the destination match. Traffic will be routed to this ID. If this is set, no other destination ID or ARN can be set.

null