Route Module
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-routemodule, 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
| Name | Version |
|---|---|
| terraform | >= 1.0.0 |
| aws | >= 4.5.0 |
Providers
| Name | Version |
|---|---|
| aws | >= 4.5.0 |
Modules
No modules.
Resources
| Name | Type |
|---|---|
| aws_route.this | resource |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| carrier_gateway_id | 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. | string | null | no |
| core_network_arn | 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. | string | null | no |
| destination_cidr_block | The IPv4 CIDR address block used for the destination match. Routing decisions are based on the most specific match. | string | null | no |
| destination_ipv6_cidr_block | The IPv6 CIDR address block used for the destination match. Routing decisions are based on the most specific match. | string | null | no |
| destination_prefix_list_id | The ID of a prefix list used for the destination match. | string | null | no |
| egress_only_gateway_id | 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. | string | null | no |
| gateway_id | 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. | string | null | no |
| local_gateway_id | 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. | string | null | no |
| nat_gateway_id | 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. | string | null | no |
| network_interface_id | 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. | string | null | no |
| route_table_ids | List of route table IDs to associate with the route | list(any) | n/a | yes |
| transit_gateway_id | 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. | string | null | no |
| vpc_endpoint_id | 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. | string | null | no |
| vpc_peering_connection_id | 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. | string | null | no |
Outputs
| Name | Description |
|---|---|
| ids | A map of IDs of the route resources. |
| states | A map of states of the route resources. |
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S ROUTE MODULE
# ------------------------------------------------------------------------------------------------------
module "route" {
source = "git::git@github.com:gruntwork-io/terraform-aws-vpc.git//modules/route?ref=v0.28.7"
# ----------------------------------------------------------------------------------------------------
# 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
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S ROUTE MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-vpc.git//modules/route?ref=v0.28.7"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# 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
- Inputs
- Outputs
Required
route_table_idslist(any)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_idstringThe 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.
nullcore_network_arnstringThe 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.
nulldestination_cidr_blockstringThe IPv4 CIDR address block used for the destination match. Routing decisions are based on the most specific match.
nullThe IPv6 CIDR address block used for the destination match. Routing decisions are based on the most specific match.
nullThe ID of a prefix list used for the destination match.
nullegress_only_gateway_idstringThe 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.
nullgateway_idstringThe 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.
nulllocal_gateway_idstringThe 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.
nullnat_gateway_idstringThe 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.
nullnetwork_interface_idstringThe 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.
nulltransit_gateway_idstringThe 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.
nullvpc_endpoint_idstringThe 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.
nullThe 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