Provides a resource to manage a default route table of a VPC. This resource can manage the default route table of the default or a non-default VPC.
Every VPC has a default route table that can be managed but not destroyed. When Terraform first adopts a default route table, it immediately removes all defined routes. It then proceeds to create any routes specified in the configuration. This step is required so that only the routes specified in the configuration exist in the default route table.
For more information, see the Amazon VPC User Guide on Route Tables. For information about managing normal route tables in Terraform, see aws_route_table
.
resource "aws_default_route_table" "example" {
default_route_table_id = aws_vpc.example.default_route_table_id
route {
cidr_block = "10.0.1.0/24"
gateway_id = aws_internet_gateway.example.id
}
route {
ipv6_cidr_block = "::/0"
egress_only_gateway_id = aws_egress_only_internet_gateway.example.id
}
tags = {
Name = "example"
}
}
To subsequently remove all managed routes:
resource "aws_default_route_table" "example" {
default_route_table_id = aws_vpc.example.default_route_table_id
route = []
tags = {
Name = "example"
}
}
The following arguments are required:
default_route_table_id
- (Required) ID of the default route table.The following arguments are optional:
propagating_vgws
- (Optional) List of virtual gateways for propagation.route
- (Optional) Configuration block of routes. Detailed below. This argument is processed in attribute-as-blocks mode. This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above.tags
- (Optional) Map of tags to assign to the resource. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.This argument is processed in attribute-as-blocks mode.
One of the following destination arguments must be supplied:
cidr_block
- (Required) The CIDR block of the route.ipv6_cidr_block
- (Optional) The Ipv6 CIDR block of the routedestination_prefix_list_id
- (Optional) The ID of a managed prefix list destination of the route.One of the following target arguments must be supplied:
core_network_arn
- (Optional) The Amazon Resource Name (ARN) of a core network.egress_only_gateway_id
- (Optional) Identifier of a VPC Egress Only Internet Gateway.gateway_id
- (Optional) Identifier of a VPC internet gateway or a virtual private gateway.instance_id
- (Optional) Identifier of an EC2 instance.nat_gateway_id
- (Optional) Identifier of a VPC NAT gateway.network_interface_id
- (Optional) Identifier of an EC2 network interface.transit_gateway_id
- (Optional) Identifier of an EC2 Transit Gateway.vpc_endpoint_id
- (Optional) Identifier of a VPC Endpoint. This route must be removed prior to VPC Endpoint deletion.vpc_peering_connection_id
- (Optional) Identifier of a VPC peering connection.Note that the default route, mapping the VPC's CIDR block to "local", is created implicitly and cannot be specified.
This resource exports the following attributes in addition to the arguments above:
id
- ID of the route table.arn
- The ARN of the route table.owner_id
- ID of the AWS account that owns the route table.tags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.vpc_id
- ID of the VPC.create
- (Default 2m
)update
- (Default 2m
)In Terraform v1.5.0 and later, use an import
block to import Default VPC route tables using the vpc_id
. For example:
import {
to = aws_default_route_table.example
id = "vpc-33cc44dd"
}
Using terraform import
, import Default VPC route tables using the vpc_id
. For example:
% terraform import aws_default_route_table.example vpc-33cc44dd