Route class
Provides a resource to create a routing table entry (a route) in a VPC routing table.
> NOTE on gatewayId attribute: The AWS API is very forgiving with the resource ID passed in the gatewayId attribute. For example an aws.ec2.Route resource can be created with an aws.ec2.NatGateway or aws.ec2.EgressOnlyInternetGateway ID specified for the gatewayId attribute. Specifying anything other than an aws.ec2.InternetGateway or aws.ec2.VpnGateway ID will lead to this provider reporting a permanent diff between your configuration and recorded state, as the AWS API returns the more-specific attribute. If you are experiencing constant diffs with an aws.ec2.Route resource, the first thing to check is that the correct attribute is being specified.
> NOTE on combining vpcEndpointId and destinationPrefixListId attributes: To associate a Gateway VPC Endpoint (such as S3) with destination prefix list, use the aws.ec2.VpcEndpointRouteTableAssociation resource instead.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const r = new aws.ec2.Route("r", {
routeTableId: testing.id,
destinationCidrBlock: "10.0.1.0/22",
vpcPeeringConnectionId: "pcx-45ff3dc1",
});
import pulumi
import pulumi_aws as aws
r = aws.ec2.Route("r",
route_table_id=testing["id"],
destination_cidr_block="10.0.1.0/22",
vpc_peering_connection_id="pcx-45ff3dc1")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var r = new Aws.Ec2.Route("r", new()
{
RouteTableId = testing.Id,
DestinationCidrBlock = "10.0.1.0/22",
VpcPeeringConnectionId = "pcx-45ff3dc1",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ec2.NewRoute(ctx, "r", &ec2.RouteArgs{
RouteTableId: pulumi.Any(testing.Id),
DestinationCidrBlock: pulumi.String("10.0.1.0/22"),
VpcPeeringConnectionId: pulumi.String("pcx-45ff3dc1"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_ec2_route" "r" {
route_table_id = testing.id
destination_cidr_block = "10.0.1.0/22"
vpc_peering_connection_id = "pcx-45ff3dc1"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Route;
import com.pulumi.aws.ec2.RouteArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var r = new Route("r", RouteArgs.builder()
.routeTableId(testing.id())
.destinationCidrBlock("10.0.1.0/22")
.vpcPeeringConnectionId("pcx-45ff3dc1")
.build());
}
}
resources:
r:
type: aws:ec2:Route
properties:
routeTableId: ${testing.id}
destinationCidrBlock: 10.0.1.0/22
vpcPeeringConnectionId: pcx-45ff3dc1
Example IPv6 Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const vpc = new aws.ec2.Vpc("vpc", {
cidrBlock: "10.1.0.0/16",
assignGeneratedIpv6CidrBlock: true,
});
const egress = new aws.ec2.EgressOnlyInternetGateway("egress", {vpcId: vpc.id});
const r = new aws.ec2.Route("r", {
routeTableId: "rtb-4fbb3ac4",
destinationIpv6CidrBlock: "::/0",
egressOnlyGatewayId: egress.id,
});
import pulumi
import pulumi_aws as aws
vpc = aws.ec2.Vpc("vpc",
cidr_block="10.1.0.0/16",
assign_generated_ipv6_cidr_block=True)
egress = aws.ec2.EgressOnlyInternetGateway("egress", vpc_id=vpc.id)
r = aws.ec2.Route("r",
route_table_id="rtb-4fbb3ac4",
destination_ipv6_cidr_block="::/0",
egress_only_gateway_id=egress.id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var vpc = new Aws.Ec2.Vpc("vpc", new()
{
CidrBlock = "10.1.0.0/16",
AssignGeneratedIpv6CidrBlock = true,
});
var egress = new Aws.Ec2.EgressOnlyInternetGateway("egress", new()
{
VpcId = vpc.Id,
});
var r = new Aws.Ec2.Route("r", new()
{
RouteTableId = "rtb-4fbb3ac4",
DestinationIpv6CidrBlock = "::/0",
EgressOnlyGatewayId = egress.Id,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
vpc, err := ec2.NewVpc(ctx, "vpc", &ec2.VpcArgs{
CidrBlock: pulumi.String("10.1.0.0/16"),
AssignGeneratedIpv6CidrBlock: pulumi.Bool(true),
})
if err != nil {
return err
}
egress, err := ec2.NewEgressOnlyInternetGateway(ctx, "egress", &ec2.EgressOnlyInternetGatewayArgs{
VpcId: vpc.ID().ToIDOutput().ToStringOutput(),
})
if err != nil {
return err
}
_, err = ec2.NewRoute(ctx, "r", &ec2.RouteArgs{
RouteTableId: pulumi.String("rtb-4fbb3ac4"),
DestinationIpv6CidrBlock: pulumi.String("::/0"),
EgressOnlyGatewayId: egress.ID().ToIDOutput().ToStringOutput(),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_ec2_vpc" "vpc" {
cidr_block = "10.1.0.0/16"
assign_generated_ipv6_cidr_block = true
}
resource "aws_ec2_egressonlyinternetgateway" "egress" {
vpc_id = aws_ec2_vpc.vpc.id
}
resource "aws_ec2_route" "r" {
route_table_id = "rtb-4fbb3ac4"
destination_ipv6_cidr_block = "::/0"
egress_only_gateway_id = aws_ec2_egressonlyinternetgateway.egress.id
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.ec2.EgressOnlyInternetGateway;
import com.pulumi.aws.ec2.EgressOnlyInternetGatewayArgs;
import com.pulumi.aws.ec2.Route;
import com.pulumi.aws.ec2.RouteArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var vpc = new Vpc("vpc", VpcArgs.builder()
.cidrBlock("10.1.0.0/16")
.assignGeneratedIpv6CidrBlock(true)
.build());
var egress = new EgressOnlyInternetGateway("egress", EgressOnlyInternetGatewayArgs.builder()
.vpcId(vpc.id())
.build());
var r = new Route("r", RouteArgs.builder()
.routeTableId("rtb-4fbb3ac4")
.destinationIpv6CidrBlock("::/0")
.egressOnlyGatewayId(egress.id())
.build());
}
}
resources:
vpc:
type: aws:ec2:Vpc
properties:
cidrBlock: 10.1.0.0/16
assignGeneratedIpv6CidrBlock: true
egress:
type: aws:ec2:EgressOnlyInternetGateway
properties:
vpcId: ${vpc.id}
r:
type: aws:ec2:Route
properties:
routeTableId: rtb-4fbb3ac4
destinationIpv6CidrBlock: ::/0
egressOnlyGatewayId: ${egress.id}
Import
Identity Schema
Required
routeTableId- (String) ID of the route table.
Optional
> Exactly one of of destinationCidrBlock, destinationIpv6CidrBlock, or destinationPrefixListId is required.
accountId(String) AWS Account where this resource is managed.destinationCidrBlock- (String) Destination IPv4 CIDR block.destinationIpv6CidrBlock- (String) Destination IPv6 CIDR block.destinationPrefixListId- (String) Destination IPv6 CIDR block.region(String) Region where this resource is managed.
Import a route in route table rtb-656C65616E6F72 with an IPv6 destination CIDR of 2620:0:2d0:200::8/125:
Import a route in route table rtb-656C65616E6F72 with a managed prefix list destination of pl-0570a1d2d725c16be:
Using pulumi import to import individual routes using ROUTETABLEID_DESTINATION. Import local routes using the VPC's IPv4 or IPv6 CIDR blocks. For example:
Import a route in route table rtb-656C65616E6F72 with an IPv4 destination CIDR of 10.42.0.0/16:
$ pulumi import aws:ec2/route:Route my_route rtb-656C65616E6F72_10.42.0.0/16
Import a route in route table rtb-656C65616E6F72 with an IPv6 destination CIDR of 2620:0:2d0:200::8/125:
$ pulumi import aws:ec2/route:Route my_route rtb-656C65616E6F72_2620:0:2d0:200::8/125
Import a route in route table rtb-656C65616E6F72 with a managed prefix list destination of pl-0570a1d2d725c16be:
$ pulumi import aws:ec2/route:Route my_route rtb-656C65616E6F72_pl-0570a1d2d725c16be
Constructors
- Route(String name, {RouteArgs? args, CustomResourceOptions? options})
-
Creates a new Route.
nameThe Pulumi resource name.argsArguments used to configure this Route. The set of arguments for Route.optionsResource options controlling this resource's behavior. - Route.reference(String urn)
- Creates a typed reference to an existing Route resource.
Properties
-
carrierGatewayId
↔ Output<
String?> -
Identifier of a carrier gateway. This attribute can only be used when the VPC contains a subnet which is associated with a Wavelength Zone.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
coreNetworkArn
↔ Output<
String?> -
ARN of a core network.
latefinal
-
destinationCidrBlock
↔ Output<
String?> -
The destination CIDR block.
latefinal
-
destinationIpv6CidrBlock
↔ Output<
String?> -
The destination IPv6 CIDR block.
latefinal
-
destinationPrefixListId
↔ Output<
String?> -
The ID of a managed prefix list destination.
latefinal
-
egressOnlyGatewayId
↔ Output<
String?> -
Identifier of a VPC Egress Only Internet Gateway.
latefinal
-
gatewayId
↔ Output<
String?> -
Identifier of a VPC internet gateway or a virtual private gateway. Specify
localwhen updating a previously imported local route.latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
-
instanceId
↔ Output<
String> -
Identifier of an EC2 instance.
latefinal
-
instanceOwnerId
↔ Output<
String> -
The AWS account ID of the owner of the EC2 instance.
latefinal
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
localGatewayId
↔ Output<
String?> -
Identifier of a Outpost local gateway.
latefinal
-
natGatewayId
↔ Output<
String?> -
Identifier of a VPC NAT gateway.
latefinal
-
networkInterfaceId
↔ Output<
String> -
Identifier of an EC2 network interface.
latefinal
-
odbNetworkArn
↔ Output<
String?> -
ARN of an ODB network.
latefinal
-
origin
↔ Output<
String> -
How the route was created -
CreateRouteTable,CreateRouteorEnableVgwRoutePropagation.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
routeTableId
↔ Output<
String> -
The ID of the routing table.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
↔ Output<
String> -
The state of the route -
activeorblackhole.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
transitGatewayId
↔ Output<
String?> -
Identifier of an EC2 Transit Gateway.
latefinal
-
urn
↔ Output<
String> -
latefinalinherited
-
vpcEndpointId
↔ Output<
String?> -
Identifier of a VPC Endpoint.
latefinal
-
vpcPeeringConnectionId
↔ Output<
String?> -
Identifier of a VPC peering connection.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited