AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

DefaultRouteTable

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.

NOTE: This is an advanced resource with special caveats. Please read this document in its entirety before using this resource. The aws.ec2.DefaultRouteTable resource behaves differently from normal resources. This provider does not create this resource but instead attempts to “adopt” it into management. Do not use both aws.ec2.DefaultRouteTable to manage a default route table and aws.ec2.MainRouteTableAssociation with the same VPC due to possible route conflicts. See aws.ec2.MainRouteTableAssociation documentation for more details.

Every VPC has a default route table that can be managed but not destroyed. When the provider 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 this provider, see aws.ec2.RouteTable.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var example = new Aws.Ec2.DefaultRouteTable("example", new Aws.Ec2.DefaultRouteTableArgs
        {
            DefaultRouteTableId = aws_vpc.Example.Default_route_table_id,
            Routes = 
            {
                new Aws.Ec2.Inputs.DefaultRouteTableRouteArgs
                {
                    CidrBlock = "10.0.1.0/24",
                    GatewayId = aws_internet_gateway.Example.Id,
                },
                new Aws.Ec2.Inputs.DefaultRouteTableRouteArgs
                {
                    Ipv6CidrBlock = "::/0",
                    EgressOnlyGatewayId = aws_egress_only_internet_gateway.Example.Id,
                },
            },
            Tags = 
            {
                { "Name", "example" },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.NewDefaultRouteTable(ctx, "example", &ec2.DefaultRouteTableArgs{
			DefaultRouteTableId: pulumi.Any(aws_vpc.Example.Default_route_table_id),
			Routes: ec2.DefaultRouteTableRouteArray{
				&ec2.DefaultRouteTableRouteArgs{
					CidrBlock: pulumi.String("10.0.1.0/24"),
					GatewayId: pulumi.Any(aws_internet_gateway.Example.Id),
				},
				&ec2.DefaultRouteTableRouteArgs{
					Ipv6CidrBlock:       pulumi.String("::/0"),
					EgressOnlyGatewayId: pulumi.Any(aws_egress_only_internet_gateway.Example.Id),
				},
			},
			Tags: pulumi.StringMap{
				"Name": pulumi.String("example"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new DefaultRouteTable("example", DefaultRouteTableArgs.builder()        
            .defaultRouteTableId(aws_vpc.example().default_route_table_id())
            .routes(            
                DefaultRouteTableRouteArgs.builder()
                    .cidrBlock("10.0.1.0/24")
                    .gatewayId(aws_internet_gateway.example().id())
                    .build(),
                DefaultRouteTableRouteArgs.builder()
                    .ipv6CidrBlock("::/0")
                    .egressOnlyGatewayId(aws_egress_only_internet_gateway.example().id())
                    .build())
            .tags(Map.of("Name", "example"))
            .build());

    }
}
import pulumi
import pulumi_aws as aws

example = aws.ec2.DefaultRouteTable("example",
    default_route_table_id=aws_vpc["example"]["default_route_table_id"],
    routes=[
        aws.ec2.DefaultRouteTableRouteArgs(
            cidr_block="10.0.1.0/24",
            gateway_id=aws_internet_gateway["example"]["id"],
        ),
        aws.ec2.DefaultRouteTableRouteArgs(
            ipv6_cidr_block="::/0",
            egress_only_gateway_id=aws_egress_only_internet_gateway["example"]["id"],
        ),
    ],
    tags={
        "Name": "example",
    })
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.ec2.DefaultRouteTable("example", {
    defaultRouteTableId: aws_vpc.example.default_route_table_id,
    routes: [
        {
            cidrBlock: "10.0.1.0/24",
            gatewayId: aws_internet_gateway.example.id,
        },
        {
            ipv6CidrBlock: "::/0",
            egressOnlyGatewayId: aws_egress_only_internet_gateway.example.id,
        },
    ],
    tags: {
        Name: "example",
    },
});
resources:
  example:
    type: aws:ec2:DefaultRouteTable
    properties:
      defaultRouteTableId: ${aws_vpc.example.default_route_table_id}
      routes:
        - cidrBlock: 10.0.1.0/24
          gatewayId: ${aws_internet_gateway.example.id}
        - ipv6CidrBlock: ::/0
          egressOnlyGatewayId: ${aws_egress_only_internet_gateway.example.id}
      tags:
        Name: example

Create a DefaultRouteTable Resource

new DefaultRouteTable(name: string, args: DefaultRouteTableArgs, opts?: CustomResourceOptions);
@overload
def DefaultRouteTable(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      default_route_table_id: Optional[str] = None,
                      propagating_vgws: Optional[Sequence[str]] = None,
                      routes: Optional[Sequence[DefaultRouteTableRouteArgs]] = None,
                      tags: Optional[Mapping[str, str]] = None)
@overload
def DefaultRouteTable(resource_name: str,
                      args: DefaultRouteTableArgs,
                      opts: Optional[ResourceOptions] = None)
func NewDefaultRouteTable(ctx *Context, name string, args DefaultRouteTableArgs, opts ...ResourceOption) (*DefaultRouteTable, error)
public DefaultRouteTable(string name, DefaultRouteTableArgs args, CustomResourceOptions? opts = null)
public DefaultRouteTable(String name, DefaultRouteTableArgs args)
public DefaultRouteTable(String name, DefaultRouteTableArgs args, CustomResourceOptions options)
type: aws:ec2:DefaultRouteTable
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args DefaultRouteTableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args DefaultRouteTableArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args DefaultRouteTableArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args DefaultRouteTableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args DefaultRouteTableArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

DefaultRouteTable Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The DefaultRouteTable resource accepts the following input properties:

DefaultRouteTableId string

ID of the default route table.

PropagatingVgws List<string>

List of virtual gateways for propagation.

Routes List<Pulumi.Aws.Ec2.Inputs.DefaultRouteTableRouteArgs>

Set of objects. Detailed below

Tags Dictionary<string, string>

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.

DefaultRouteTableId string

ID of the default route table.

PropagatingVgws []string

List of virtual gateways for propagation.

Routes []DefaultRouteTableRouteArgs

Set of objects. Detailed below

Tags map[string]string

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.

defaultRouteTableId String

ID of the default route table.

propagatingVgws List<String>

List of virtual gateways for propagation.

routes List<DefaultRouteTableRouteArgs>

Set of objects. Detailed below

tags Map<String,String>

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.

defaultRouteTableId string

ID of the default route table.

propagatingVgws string[]

List of virtual gateways for propagation.

routes DefaultRouteTableRouteArgs[]

Set of objects. Detailed below

tags {[key: string]: string}

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.

default_route_table_id str

ID of the default route table.

propagating_vgws Sequence[str]

List of virtual gateways for propagation.

routes Sequence[DefaultRouteTableRouteArgs]

Set of objects. Detailed below

tags Mapping[str, str]

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.

defaultRouteTableId String

ID of the default route table.

propagatingVgws List<String>

List of virtual gateways for propagation.

routes List<Property Map>

Set of objects. Detailed below

tags Map<String>

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.

Outputs

All input properties are implicitly available as output properties. Additionally, the DefaultRouteTable resource produces the following output properties:

Arn string

The ARN of the route table.

Id string

The provider-assigned unique ID for this managed resource.

OwnerId string

ID of the AWS account that owns the route table.

TagsAll Dictionary<string, string>

A map of tags assigned to the resource, including those inherited from the provider .

VpcId string

ID of the VPC.

Arn string

The ARN of the route table.

Id string

The provider-assigned unique ID for this managed resource.

OwnerId string

ID of the AWS account that owns the route table.

TagsAll map[string]string

A map of tags assigned to the resource, including those inherited from the provider .

VpcId string

ID of the VPC.

arn String

The ARN of the route table.

id String

The provider-assigned unique ID for this managed resource.

ownerId String

ID of the AWS account that owns the route table.

tagsAll Map<String,String>

A map of tags assigned to the resource, including those inherited from the provider .

vpcId String

ID of the VPC.

arn string

The ARN of the route table.

id string

The provider-assigned unique ID for this managed resource.

ownerId string

ID of the AWS account that owns the route table.

tagsAll {[key: string]: string}

A map of tags assigned to the resource, including those inherited from the provider .

vpcId string

ID of the VPC.

arn str

The ARN of the route table.

id str

The provider-assigned unique ID for this managed resource.

owner_id str

ID of the AWS account that owns the route table.

tags_all Mapping[str, str]

A map of tags assigned to the resource, including those inherited from the provider .

vpc_id str

ID of the VPC.

arn String

The ARN of the route table.

id String

The provider-assigned unique ID for this managed resource.

ownerId String

ID of the AWS account that owns the route table.

tagsAll Map<String>

A map of tags assigned to the resource, including those inherited from the provider .

vpcId String

ID of the VPC.

Look up an Existing DefaultRouteTable Resource

Get an existing DefaultRouteTable resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: DefaultRouteTableState, opts?: CustomResourceOptions): DefaultRouteTable
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        default_route_table_id: Optional[str] = None,
        owner_id: Optional[str] = None,
        propagating_vgws: Optional[Sequence[str]] = None,
        routes: Optional[Sequence[DefaultRouteTableRouteArgs]] = None,
        tags: Optional[Mapping[str, str]] = None,
        tags_all: Optional[Mapping[str, str]] = None,
        vpc_id: Optional[str] = None) -> DefaultRouteTable
func GetDefaultRouteTable(ctx *Context, name string, id IDInput, state *DefaultRouteTableState, opts ...ResourceOption) (*DefaultRouteTable, error)
public static DefaultRouteTable Get(string name, Input<string> id, DefaultRouteTableState? state, CustomResourceOptions? opts = null)
public static DefaultRouteTable get(String name, Output<String> id, DefaultRouteTableState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Arn string

The ARN of the route table.

DefaultRouteTableId string

ID of the default route table.

OwnerId string

ID of the AWS account that owns the route table.

PropagatingVgws List<string>

List of virtual gateways for propagation.

Routes List<Pulumi.Aws.Ec2.Inputs.DefaultRouteTableRouteArgs>

Set of objects. Detailed below

Tags Dictionary<string, string>

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.

TagsAll Dictionary<string, string>

A map of tags assigned to the resource, including those inherited from the provider .

VpcId string

ID of the VPC.

Arn string

The ARN of the route table.

DefaultRouteTableId string

ID of the default route table.

OwnerId string

ID of the AWS account that owns the route table.

PropagatingVgws []string

List of virtual gateways for propagation.

Routes []DefaultRouteTableRouteArgs

Set of objects. Detailed below

Tags map[string]string

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.

TagsAll map[string]string

A map of tags assigned to the resource, including those inherited from the provider .

VpcId string

ID of the VPC.

arn String

The ARN of the route table.

defaultRouteTableId String

ID of the default route table.

ownerId String

ID of the AWS account that owns the route table.

propagatingVgws List<String>

List of virtual gateways for propagation.

routes List<DefaultRouteTableRouteArgs>

Set of objects. Detailed below

tags Map<String,String>

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.

tagsAll Map<String,String>

A map of tags assigned to the resource, including those inherited from the provider .

vpcId String

ID of the VPC.

arn string

The ARN of the route table.

defaultRouteTableId string

ID of the default route table.

ownerId string

ID of the AWS account that owns the route table.

propagatingVgws string[]

List of virtual gateways for propagation.

routes DefaultRouteTableRouteArgs[]

Set of objects. Detailed below

tags {[key: string]: string}

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.

tagsAll {[key: string]: string}

A map of tags assigned to the resource, including those inherited from the provider .

vpcId string

ID of the VPC.

arn str

The ARN of the route table.

default_route_table_id str

ID of the default route table.

owner_id str

ID of the AWS account that owns the route table.

propagating_vgws Sequence[str]

List of virtual gateways for propagation.

routes Sequence[DefaultRouteTableRouteArgs]

Set of objects. Detailed below

tags Mapping[str, str]

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.

tags_all Mapping[str, str]

A map of tags assigned to the resource, including those inherited from the provider .

vpc_id str

ID of the VPC.

arn String

The ARN of the route table.

defaultRouteTableId String

ID of the default route table.

ownerId String

ID of the AWS account that owns the route table.

propagatingVgws List<String>

List of virtual gateways for propagation.

routes List<Property Map>

Set of objects. Detailed below

tags Map<String>

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.

tagsAll Map<String>

A map of tags assigned to the resource, including those inherited from the provider .

vpcId String

ID of the VPC.

Supporting Types

DefaultRouteTableRoute

CidrBlock string

The CIDR block of the route.

CoreNetworkArn string

The Amazon Resource Name (ARN) of a core network.

DestinationPrefixListId string

The ID of a managed prefix list destination of the route.

EgressOnlyGatewayId string

Identifier of a VPC Egress Only Internet Gateway.

GatewayId string

Identifier of a VPC internet gateway or a virtual private gateway.

InstanceId string

Identifier of an EC2 instance.

Ipv6CidrBlock string

The Ipv6 CIDR block of the route

NatGatewayId string

Identifier of a VPC NAT gateway.

NetworkInterfaceId string

Identifier of an EC2 network interface.

TransitGatewayId string

Identifier of an EC2 Transit Gateway.

VpcEndpointId string

Identifier of a VPC Endpoint. This route must be removed prior to VPC Endpoint deletion.

VpcPeeringConnectionId string

Identifier of a VPC peering connection.

CidrBlock string

The CIDR block of the route.

CoreNetworkArn string

The Amazon Resource Name (ARN) of a core network.

DestinationPrefixListId string

The ID of a managed prefix list destination of the route.

EgressOnlyGatewayId string

Identifier of a VPC Egress Only Internet Gateway.

GatewayId string

Identifier of a VPC internet gateway or a virtual private gateway.

InstanceId string

Identifier of an EC2 instance.

Ipv6CidrBlock string

The Ipv6 CIDR block of the route

NatGatewayId string

Identifier of a VPC NAT gateway.

NetworkInterfaceId string

Identifier of an EC2 network interface.

TransitGatewayId string

Identifier of an EC2 Transit Gateway.

VpcEndpointId string

Identifier of a VPC Endpoint. This route must be removed prior to VPC Endpoint deletion.

VpcPeeringConnectionId string

Identifier of a VPC peering connection.

cidrBlock String

The CIDR block of the route.

coreNetworkArn String

The Amazon Resource Name (ARN) of a core network.

destinationPrefixListId String

The ID of a managed prefix list destination of the route.

egressOnlyGatewayId String

Identifier of a VPC Egress Only Internet Gateway.

gatewayId String

Identifier of a VPC internet gateway or a virtual private gateway.

instanceId String

Identifier of an EC2 instance.

ipv6CidrBlock String

The Ipv6 CIDR block of the route

natGatewayId String

Identifier of a VPC NAT gateway.

networkInterfaceId String

Identifier of an EC2 network interface.

transitGatewayId String

Identifier of an EC2 Transit Gateway.

vpcEndpointId String

Identifier of a VPC Endpoint. This route must be removed prior to VPC Endpoint deletion.

vpcPeeringConnectionId String

Identifier of a VPC peering connection.

cidrBlock string

The CIDR block of the route.

coreNetworkArn string

The Amazon Resource Name (ARN) of a core network.

destinationPrefixListId string

The ID of a managed prefix list destination of the route.

egressOnlyGatewayId string

Identifier of a VPC Egress Only Internet Gateway.

gatewayId string

Identifier of a VPC internet gateway or a virtual private gateway.

instanceId string

Identifier of an EC2 instance.

ipv6CidrBlock string

The Ipv6 CIDR block of the route

natGatewayId string

Identifier of a VPC NAT gateway.

networkInterfaceId string

Identifier of an EC2 network interface.

transitGatewayId string

Identifier of an EC2 Transit Gateway.

vpcEndpointId string

Identifier of a VPC Endpoint. This route must be removed prior to VPC Endpoint deletion.

vpcPeeringConnectionId string

Identifier of a VPC peering connection.

cidr_block str

The CIDR block of the route.

core_network_arn str

The Amazon Resource Name (ARN) of a core network.

destination_prefix_list_id str

The ID of a managed prefix list destination of the route.

egress_only_gateway_id str

Identifier of a VPC Egress Only Internet Gateway.

gateway_id str

Identifier of a VPC internet gateway or a virtual private gateway.

instance_id str

Identifier of an EC2 instance.

ipv6_cidr_block str

The Ipv6 CIDR block of the route

nat_gateway_id str

Identifier of a VPC NAT gateway.

network_interface_id str

Identifier of an EC2 network interface.

transit_gateway_id str

Identifier of an EC2 Transit Gateway.

vpc_endpoint_id str

Identifier of a VPC Endpoint. This route must be removed prior to VPC Endpoint deletion.

vpc_peering_connection_id str

Identifier of a VPC peering connection.

cidrBlock String

The CIDR block of the route.

coreNetworkArn String

The Amazon Resource Name (ARN) of a core network.

destinationPrefixListId String

The ID of a managed prefix list destination of the route.

egressOnlyGatewayId String

Identifier of a VPC Egress Only Internet Gateway.

gatewayId String

Identifier of a VPC internet gateway or a virtual private gateway.

instanceId String

Identifier of an EC2 instance.

ipv6CidrBlock String

The Ipv6 CIDR block of the route

natGatewayId String

Identifier of a VPC NAT gateway.

networkInterfaceId String

Identifier of an EC2 network interface.

transitGatewayId String

Identifier of an EC2 Transit Gateway.

vpcEndpointId String

Identifier of a VPC Endpoint. This route must be removed prior to VPC Endpoint deletion.

vpcPeeringConnectionId String

Identifier of a VPC peering connection.

Import

Default VPC route tables can be imported using the vpc_id, e.g.,

 $ pulumi import aws:ec2/defaultRouteTable:DefaultRouteTable example vpc-33cc44dd

[aws-route-tables]http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Route_Tables.html#Route_Replacing_Main_Table [tf-route-tables]/docs/providers/aws/r/route_table.html [tf-main-route-table-association]/docs/providers/aws/r/main_route_table_association.html

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.