Route

Provides a resource to create a routing table entry (a route) in 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.

Example IPv6 Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const vpc = new aws.ec2.Vpc("vpc", {
    assignGeneratedIpv6CidrBlock: true,
    cidrBlock: "10.1.0.0/16",
});
const egress = new aws.ec2.EgressOnlyInternetGateway("egress", {
    vpcId: vpc.id,
});
const route = new aws.ec2.Route("r", {
    destinationIpv6CidrBlock: "::/0",
    egressOnlyGatewayId: egress.id,
    routeTableId: "rtb-4fbb3ac4",
});
import pulumi
import pulumi_aws as aws

vpc = aws.ec2.Vpc("vpc",
    assign_generated_ipv6_cidr_block=True,
    cidr_block="10.1.0.0/16")
egress = aws.ec2.EgressOnlyInternetGateway("egress", vpc_id=vpc.id)
route = aws.ec2.Route("route",
    destination_ipv6_cidr_block="::/0",
    egress_only_gateway_id=egress.id,
    route_table_id="rtb-4fbb3ac4")
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var vpc = new Aws.Ec2.Vpc("vpc", new Aws.Ec2.VpcArgs
        {
            AssignGeneratedIpv6CidrBlock = true,
            CidrBlock = "10.1.0.0/16",
        });
        var egress = new Aws.Ec2.EgressOnlyInternetGateway("egress", new Aws.Ec2.EgressOnlyInternetGatewayArgs
        {
            VpcId = vpc.Id,
        });
        var route = new Aws.Ec2.Route("route", new Aws.Ec2.RouteArgs
        {
            DestinationIpv6CidrBlock = "::/0",
            EgressOnlyGatewayId = egress.Id,
            RouteTableId = "rtb-4fbb3ac4",
        });
    }

}
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 {
		vpc, err := ec2.NewVpc(ctx, "vpc", &ec2.VpcArgs{
			AssignGeneratedIpv6CidrBlock: pulumi.Bool(true),
			CidrBlock:                    pulumi.String("10.1.0.0/16"),
		})
		if err != nil {
			return err
		}
		egress, err := ec2.NewEgressOnlyInternetGateway(ctx, "egress", &ec2.EgressOnlyInternetGatewayArgs{
			VpcId: vpc.ID(),
		})
		if err != nil {
			return err
		}
		_, err = ec2.NewRoute(ctx, "route", &ec2.RouteArgs{
			DestinationIpv6CidrBlock: pulumi.String("::/0"),
			EgressOnlyGatewayId:      egress.ID(),
			RouteTableId:             pulumi.String("rtb-4fbb3ac4"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var route = new Aws.Ec2.Route("route", new Aws.Ec2.RouteArgs
        {
            RouteTableId = "rtb-4fbb3ac4",
            DestinationCidrBlock = "10.0.1.0/22",
            VpcPeeringConnectionId = "pcx-45ff3dc1",
        }, new CustomResourceOptions
        {
            DependsOn = 
            {
                "aws_route_table.testing",
            },
        });
    }

}
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.NewRoute(ctx, "route", &ec2.RouteArgs{
            RouteTableId:           pulumi.String("rtb-4fbb3ac4"),
            DestinationCidrBlock:   pulumi.String("10.0.1.0/22"),
            VpcPeeringConnectionId: pulumi.String("pcx-45ff3dc1"),
        }, pulumi.DependsOn([]pulumi.Resource{
            "aws_route_table.testing",
        }))
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

route = aws.ec2.Route("route",
    route_table_id="rtb-4fbb3ac4",
    destination_cidr_block="10.0.1.0/22",
    vpc_peering_connection_id="pcx-45ff3dc1",
    opts=ResourceOptions(depends_on=["aws_route_table.testing"]))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const route = new aws.ec2.Route("route", {
    routeTableId: "rtb-4fbb3ac4",
    destinationCidrBlock: "10.0.1.0/22",
    vpcPeeringConnectionId: "pcx-45ff3dc1",
}, {
    dependsOn: ["aws_route_table.testing"],
});

Create a Route Resource

new Route(name: string, args: RouteArgs, opts?: CustomResourceOptions);
def Route(resource_name, opts=None, destination_cidr_block=None, destination_ipv6_cidr_block=None, egress_only_gateway_id=None, gateway_id=None, instance_id=None, nat_gateway_id=None, network_interface_id=None, route_table_id=None, transit_gateway_id=None, vpc_peering_connection_id=None, __props__=None);
func NewRoute(ctx *Context, name string, args RouteArgs, opts ...ResourceOption) (*Route, error)
public Route(string name, RouteArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args RouteArgs
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 RouteArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args RouteArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Route Resource Properties

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

Inputs

The Route resource accepts the following input properties:

RouteTableId string

The ID of the routing table.

DestinationCidrBlock string

The destination CIDR block.

DestinationIpv6CidrBlock string

The destination IPv6 CIDR block.

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.

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.

RouteTableId string

The ID of the routing table.

DestinationCidrBlock string

The destination CIDR block.

DestinationIpv6CidrBlock string

The destination IPv6 CIDR block.

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.

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.

routeTableId string

The ID of the routing table.

destinationCidrBlock string

The destination CIDR block.

destinationIpv6CidrBlock string

The destination IPv6 CIDR block.

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.

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.

route_table_id str

The ID of the routing table.

destination_cidr_block str

The destination CIDR block.

destination_ipv6_cidr_block str

The destination IPv6 CIDR block.

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.

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.

Outputs

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

DestinationPrefixListId string
Id string
The provider-assigned unique ID for this managed resource.
InstanceOwnerId string
Origin string
State string
DestinationPrefixListId string
Id string
The provider-assigned unique ID for this managed resource.
InstanceOwnerId string
Origin string
State string
destinationPrefixListId string
id string
The provider-assigned unique ID for this managed resource.
instanceOwnerId string
origin string
state string
destination_prefix_list_id str
id str
The provider-assigned unique ID for this managed resource.
instance_owner_id str
origin str
state str

Look up an Existing Route Resource

Get an existing Route 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?: RouteState, opts?: CustomResourceOptions): Route
static get(resource_name, id, opts=None, destination_cidr_block=None, destination_ipv6_cidr_block=None, destination_prefix_list_id=None, egress_only_gateway_id=None, gateway_id=None, instance_id=None, instance_owner_id=None, nat_gateway_id=None, network_interface_id=None, origin=None, route_table_id=None, state=None, transit_gateway_id=None, vpc_peering_connection_id=None, __props__=None);
func GetRoute(ctx *Context, name string, id IDInput, state *RouteState, opts ...ResourceOption) (*Route, error)
public static Route Get(string name, Input<string> id, RouteState? 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:

DestinationCidrBlock string

The destination CIDR block.

DestinationIpv6CidrBlock string

The destination IPv6 CIDR block.

DestinationPrefixListId string
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.

InstanceOwnerId string
NatGatewayId string

Identifier of a VPC NAT gateway.

NetworkInterfaceId string

Identifier of an EC2 network interface.

Origin string
RouteTableId string

The ID of the routing table.

State string
TransitGatewayId string

Identifier of an EC2 Transit Gateway.

VpcPeeringConnectionId string

Identifier of a VPC peering connection.

DestinationCidrBlock string

The destination CIDR block.

DestinationIpv6CidrBlock string

The destination IPv6 CIDR block.

DestinationPrefixListId string
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.

InstanceOwnerId string
NatGatewayId string

Identifier of a VPC NAT gateway.

NetworkInterfaceId string

Identifier of an EC2 network interface.

Origin string
RouteTableId string

The ID of the routing table.

State string
TransitGatewayId string

Identifier of an EC2 Transit Gateway.

VpcPeeringConnectionId string

Identifier of a VPC peering connection.

destinationCidrBlock string

The destination CIDR block.

destinationIpv6CidrBlock string

The destination IPv6 CIDR block.

destinationPrefixListId string
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.

instanceOwnerId string
natGatewayId string

Identifier of a VPC NAT gateway.

networkInterfaceId string

Identifier of an EC2 network interface.

origin string
routeTableId string

The ID of the routing table.

state string
transitGatewayId string

Identifier of an EC2 Transit Gateway.

vpcPeeringConnectionId string

Identifier of a VPC peering connection.

destination_cidr_block str

The destination CIDR block.

destination_ipv6_cidr_block str

The destination IPv6 CIDR block.

destination_prefix_list_id str
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.

instance_owner_id str
nat_gateway_id str

Identifier of a VPC NAT gateway.

network_interface_id str

Identifier of an EC2 network interface.

origin str
route_table_id str

The ID of the routing table.

state str
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.