RouteTable

Provides a resource to create a VPC routing table.

NOTE on Route Tables and Routes: This provider currently provides both a standalone Route resource and a Route Table resource with routes defined in-line. At this time you cannot use a Route Table with in-line routes in conjunction with any Route resources. Doing so will cause a conflict of rule settings and will overwrite rules.

NOTE on gateway_id and nat_gateway_id: The AWS API is very forgiving with these two attributes and the aws.ec2.RouteTable resource can be created with a NAT ID specified as a Gateway ID attribute. This will lead to a permanent diff between your configuration and statefile, as the API returns the correct parameters in the returned route table. If you’re experiencing constant diffs in your aws.ec2.RouteTable resources, the first thing to check is whether or not you’re specifying a NAT ID instead of a Gateway ID, or vice-versa.

NOTE on propagating_vgws and the aws.ec2.VpnGatewayRoutePropagation resource: If the propagating_vgws argument is present, it’s not supported to also define route propagations using aws.ec2.VpnGatewayRoutePropagation, since this resource will delete any propagating gateways not explicitly listed in propagating_vgws. Omit this argument when defining route propagation using the separate resource.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var routeTable = new Aws.Ec2.RouteTable("routeTable", new Aws.Ec2.RouteTableArgs
        {
            Routes = 
            {
                new Aws.Ec2.Inputs.RouteTableRouteArgs
                {
                    CidrBlock = "10.0.1.0/24",
                    GatewayId = aws_internet_gateway.Main.Id,
                },
                new Aws.Ec2.Inputs.RouteTableRouteArgs
                {
                    EgressOnlyGatewayId = aws_egress_only_internet_gateway.Foo.Id,
                    Ipv6CidrBlock = "::/0",
                },
            },
            Tags = 
            {
                { "Name", "main" },
            },
            VpcId = aws_vpc.Default.Id,
        });
    }

}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := ec2.NewRouteTable(ctx, "routeTable", &ec2.RouteTableArgs{
            Routes: ec2.RouteTableRouteArray{
                &ec2.RouteTableRouteArgs{
                    CidrBlock: pulumi.String("10.0.1.0/24"),
                    GatewayId: pulumi.String(aws_internet_gateway.Main.Id),
                },
                &ec2.RouteTableRouteArgs{
                    EgressOnlyGatewayId: pulumi.String(aws_egress_only_internet_gateway.Foo.Id),
                    Ipv6CidrBlock:       pulumi.String("::/0"),
                },
            },
            Tags: pulumi.StringMap{
                "Name": pulumi.String("main"),
            },
            VpcId: pulumi.String(aws_vpc.Default.Id),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

route_table = aws.ec2.RouteTable("routeTable",
    routes=[
        {
            "cidr_block": "10.0.1.0/24",
            "gateway_id": aws_internet_gateway["main"]["id"],
        },
        {
            "egress_only_gateway_id": aws_egress_only_internet_gateway["foo"]["id"],
            "ipv6_cidr_block": "::/0",
        },
    ],
    tags={
        "Name": "main",
    },
    vpc_id=aws_vpc["default"]["id"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const routeTable = new aws.ec2.RouteTable("r", {
    routes: [
        {
            cidrBlock: "10.0.1.0/24",
            gatewayId: aws_internet_gateway_main.id,
        },
        {
            egressOnlyGatewayId: aws_egress_only_internet_gateway_foo.id,
            ipv6CidrBlock: "::/0",
        },
    ],
    tags: {
        Name: "main",
    },
    vpcId: aws_vpc_default.id,
});

Create a RouteTable Resource

def RouteTable(resource_name, opts=None, propagating_vgws=None, routes=None, tags=None, vpc_id=None, __props__=None);
func NewRouteTable(ctx *Context, name string, args RouteTableArgs, opts ...ResourceOption) (*RouteTable, error)
public RouteTable(string name, RouteTableArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args RouteTableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args RouteTableArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args RouteTableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

RouteTable Resource Properties

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

Inputs

The RouteTable resource accepts the following input properties:

VpcId string

The VPC ID.

PropagatingVgws List<string>

A list of virtual gateways for propagation.

Routes List<RouteTableRouteArgs>

A list of route objects. Their keys are documented below.

Tags Dictionary<string, string>

A mapping of tags to assign to the resource.

VpcId string

The VPC ID.

PropagatingVgws []string

A list of virtual gateways for propagation.

Routes []RouteTableRoute

A list of route objects. Their keys are documented below.

Tags map[string]string

A mapping of tags to assign to the resource.

vpcId string

The VPC ID.

propagatingVgws string[]

A list of virtual gateways for propagation.

routes RouteTableRoute[]

A list of route objects. Their keys are documented below.

tags {[key: string]: string}

A mapping of tags to assign to the resource.

vpc_id str

The VPC ID.

propagating_vgws List[str]

A list of virtual gateways for propagation.

routes List[RouteTableRoute]

A list of route objects. Their keys are documented below.

tags Dict[str, str]

A mapping of tags to assign to the resource.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
OwnerId string

The ID of the AWS account that owns the route table.

Id string
The provider-assigned unique ID for this managed resource.
OwnerId string

The ID of the AWS account that owns the route table.

id string
The provider-assigned unique ID for this managed resource.
ownerId string

The ID of the AWS account that owns the route table.

id str
The provider-assigned unique ID for this managed resource.
owner_id str

The ID of the AWS account that owns the route table.

Look up an Existing RouteTable Resource

Get an existing RouteTable 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?: RouteTableState, opts?: CustomResourceOptions): RouteTable
static get(resource_name, id, opts=None, owner_id=None, propagating_vgws=None, routes=None, tags=None, vpc_id=None, __props__=None);
func GetRouteTable(ctx *Context, name string, id IDInput, state *RouteTableState, opts ...ResourceOption) (*RouteTable, error)
public static RouteTable Get(string name, Input<string> id, RouteTableState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

OwnerId string

The ID of the AWS account that owns the route table.

PropagatingVgws List<string>

A list of virtual gateways for propagation.

Routes List<RouteTableRouteArgs>

A list of route objects. Their keys are documented below.

Tags Dictionary<string, string>

A mapping of tags to assign to the resource.

VpcId string

The VPC ID.

OwnerId string

The ID of the AWS account that owns the route table.

PropagatingVgws []string

A list of virtual gateways for propagation.

Routes []RouteTableRoute

A list of route objects. Their keys are documented below.

Tags map[string]string

A mapping of tags to assign to the resource.

VpcId string

The VPC ID.

ownerId string

The ID of the AWS account that owns the route table.

propagatingVgws string[]

A list of virtual gateways for propagation.

routes RouteTableRoute[]

A list of route objects. Their keys are documented below.

tags {[key: string]: string}

A mapping of tags to assign to the resource.

vpcId string

The VPC ID.

owner_id str

The ID of the AWS account that owns the route table.

propagating_vgws List[str]

A list of virtual gateways for propagation.

routes List[RouteTableRoute]

A list of route objects. Their keys are documented below.

tags Dict[str, str]

A mapping of tags to assign to the resource.

vpc_id str

The VPC ID.

Supporting Types

RouteTableRoute

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

CidrBlock string

The CIDR block 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.

VpcPeeringConnectionId string

Identifier of a VPC peering connection.

CidrBlock string

The CIDR block 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.

VpcPeeringConnectionId string

Identifier of a VPC peering connection.

cidrBlock string

The CIDR block 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.

vpcPeeringConnectionId string

Identifier of a VPC peering connection.

cidr_block str

The CIDR block 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_peering_connection_id str

Identifier of a VPC peering connection.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.