GetRoute

aws.ec2.Route provides details about a specific Route.

This resource can prove useful when finding the resource associated with a CIDR. For example, finding the peering connection associated with a CIDR value.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var subnetId = config.RequireObject<dynamic>("subnetId");
        var selected = Output.Create(Aws.Ec2.GetRouteTable.InvokeAsync(new Aws.Ec2.GetRouteTableArgs
        {
            SubnetId = subnetId,
        }));
        var route = Output.Create(Aws.Ec2.GetRoute.InvokeAsync(new Aws.Ec2.GetRouteArgs
        {
            DestinationCidrBlock = "10.0.1.0/24",
            RouteTableId = aws_route_table.Selected.Id,
        }));
        var @interface = Output.Create(Aws.Ec2.GetNetworkInterface.InvokeAsync(new Aws.Ec2.GetNetworkInterfaceArgs
        {
            NetworkInterfaceId = route.Apply(route => route.NetworkInterfaceId),
        }));
    }

}
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 {
        opt0 := subnetId
        _, err := ec2.LookupRouteTable(ctx, &ec2.LookupRouteTableArgs{
            SubnetId: &opt0,
        }, nil)
        if err != nil {
            return err
        }
        opt1 := "10.0.1.0/24"
        route, err := ec2.LookupRoute(ctx, &ec2.LookupRouteArgs{
            DestinationCidrBlock: &opt1,
            RouteTableId:         aws_route_table.Selected.Id,
        }, nil)
        if err != nil {
            return err
        }
        _, err = ec2.LookupNetworkInterface(ctx, &ec2.LookupNetworkInterfaceArgs{
            NetworkInterfaceId: route.NetworkInterfaceId,
        }, nil)
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

config = pulumi.Config()
subnet_id = config.require_object("subnetId")
selected = aws.ec2.get_route_table(subnet_id=subnet_id)
route = aws.ec2.get_route(destination_cidr_block="10.0.1.0/24",
    route_table_id=aws_route_table["selected"]["id"])
interface = aws.ec2.get_network_interface(network_interface_id=route.network_interface_id)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const config = new pulumi.Config();
const subnetId = config.require("subnetId");

const selected = pulumi.output(aws.ec2.getRouteTable({
    subnetId: subnetId,
}, { async: true }));
const route = aws_route_table_selected.id.apply(id => aws.ec2.getRoute({
    destinationCidrBlock: "10.0.1.0/24",
    routeTableId: id,
}, { async: true }));
const interfaceNetworkInterface = route.apply(route => aws.ec2.getNetworkInterface({
    networkInterfaceId: route.networkInterfaceId!,
}, { async: true }));

Using GetRoute

function getRoute(args: GetRouteArgs, opts?: InvokeOptions): Promise<GetRouteResult>
function  get_route(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, opts=None)
func LookupRoute(ctx *Context, args *LookupRouteArgs, opts ...InvokeOption) (*LookupRouteResult, error)

Note: This function is named LookupRoute in the Go SDK.

public static class GetRoute {
    public static Task<GetRouteResult> InvokeAsync(GetRouteArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

RouteTableId string

The id of the specific Route Table containing the Route entry.

DestinationCidrBlock string

The CIDR block of the Route belonging to the Route Table.

DestinationIpv6CidrBlock string

The IPv6 CIDR block of the Route belonging to the Route Table.

EgressOnlyGatewayId string

The Egress Only Gateway ID of the Route belonging to the Route Table.

GatewayId string

The Gateway ID of the Route belonging to the Route Table.

InstanceId string

The Instance ID of the Route belonging to the Route Table.

NatGatewayId string

The NAT Gateway ID of the Route belonging to the Route Table.

NetworkInterfaceId string

The Network Interface ID of the Route belonging to the Route Table.

TransitGatewayId string

The EC2 Transit Gateway ID of the Route belonging to the Route Table.

VpcPeeringConnectionId string

The VPC Peering Connection ID of the Route belonging to the Route Table.

RouteTableId string

The id of the specific Route Table containing the Route entry.

DestinationCidrBlock string

The CIDR block of the Route belonging to the Route Table.

DestinationIpv6CidrBlock string

The IPv6 CIDR block of the Route belonging to the Route Table.

EgressOnlyGatewayId string

The Egress Only Gateway ID of the Route belonging to the Route Table.

GatewayId string

The Gateway ID of the Route belonging to the Route Table.

InstanceId string

The Instance ID of the Route belonging to the Route Table.

NatGatewayId string

The NAT Gateway ID of the Route belonging to the Route Table.

NetworkInterfaceId string

The Network Interface ID of the Route belonging to the Route Table.

TransitGatewayId string

The EC2 Transit Gateway ID of the Route belonging to the Route Table.

VpcPeeringConnectionId string

The VPC Peering Connection ID of the Route belonging to the Route Table.

routeTableId string

The id of the specific Route Table containing the Route entry.

destinationCidrBlock string

The CIDR block of the Route belonging to the Route Table.

destinationIpv6CidrBlock string

The IPv6 CIDR block of the Route belonging to the Route Table.

egressOnlyGatewayId string

The Egress Only Gateway ID of the Route belonging to the Route Table.

gatewayId string

The Gateway ID of the Route belonging to the Route Table.

instanceId string

The Instance ID of the Route belonging to the Route Table.

natGatewayId string

The NAT Gateway ID of the Route belonging to the Route Table.

networkInterfaceId string

The Network Interface ID of the Route belonging to the Route Table.

transitGatewayId string

The EC2 Transit Gateway ID of the Route belonging to the Route Table.

vpcPeeringConnectionId string

The VPC Peering Connection ID of the Route belonging to the Route Table.

route_table_id str

The id of the specific Route Table containing the Route entry.

destination_cidr_block str

The CIDR block of the Route belonging to the Route Table.

destination_ipv6_cidr_block str

The IPv6 CIDR block of the Route belonging to the Route Table.

egress_only_gateway_id str

The Egress Only Gateway ID of the Route belonging to the Route Table.

gateway_id str

The Gateway ID of the Route belonging to the Route Table.

instance_id str

The Instance ID of the Route belonging to the Route Table.

nat_gateway_id str

The NAT Gateway ID of the Route belonging to the Route Table.

network_interface_id str

The Network Interface ID of the Route belonging to the Route Table.

transit_gateway_id str

The EC2 Transit Gateway ID of the Route belonging to the Route Table.

vpc_peering_connection_id str

The VPC Peering Connection ID of the Route belonging to the Route Table.

GetRoute Result

The following output properties are available:

DestinationCidrBlock string
DestinationIpv6CidrBlock string
EgressOnlyGatewayId string
GatewayId string
Id string

The provider-assigned unique ID for this managed resource.

InstanceId string
NatGatewayId string
NetworkInterfaceId string
RouteTableId string
TransitGatewayId string
VpcPeeringConnectionId string
DestinationCidrBlock string
DestinationIpv6CidrBlock string
EgressOnlyGatewayId string
GatewayId string
Id string

The provider-assigned unique ID for this managed resource.

InstanceId string
NatGatewayId string
NetworkInterfaceId string
RouteTableId string
TransitGatewayId string
VpcPeeringConnectionId string
destinationCidrBlock string
destinationIpv6CidrBlock string
egressOnlyGatewayId string
gatewayId string
id string

The provider-assigned unique ID for this managed resource.

instanceId string
natGatewayId string
networkInterfaceId string
routeTableId string
transitGatewayId string
vpcPeeringConnectionId string
destination_cidr_block str
destination_ipv6_cidr_block str
egress_only_gateway_id str
gateway_id str
id str

The provider-assigned unique ID for this managed resource.

instance_id str
nat_gateway_id str
network_interface_id str
route_table_id str
transit_gateway_id str
vpc_peering_connection_id str

Package Details

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