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
        {
            RouteTableId = aws_route_table.Selected.Id,
            DestinationCidrBlock = "10.0.1.0/24",
        }));
        var @interface = route.Apply(route => Output.Create(Aws.Ec2.GetNetworkInterface.InvokeAsync(new Aws.Ec2.GetNetworkInterfaceArgs
        {
            Id = route.NetworkInterfaceId,
        })));
    }

}
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		subnetId := cfg.RequireObject("subnetId")
		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{
			RouteTableId:         aws_route_table.Selected.Id,
			DestinationCidrBlock: &opt1,
		}, nil)
		if err != nil {
			return err
		}
		opt2 := route.NetworkInterfaceId
		_, err = ec2.LookupNetworkInterface(ctx, &ec2.LookupNetworkInterfaceArgs{
			Id: &opt2,
		}, 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(route_table_id=aws_route_table["selected"]["id"],
    destination_cidr_block="10.0.1.0/24")
interface = aws.ec2.get_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.requireObject("subnetId");
const selected = aws.ec2.getRouteTable({
    subnetId: subnetId,
});
const route = aws.ec2.getRoute({
    routeTableId: aws_route_table.selected.id,
    destinationCidrBlock: "10.0.1.0/24",
});
const interface = route.then(route => aws.ec2.getNetworkInterface({
    id: route.networkInterfaceId,
}));

Using getRoute

function getRoute(args: GetRouteArgs, opts?: InvokeOptions): Promise<GetRouteResult>
def get_route(carrier_gateway_id: Optional[str] = None,
              destination_cidr_block: Optional[str] = None,
              destination_ipv6_cidr_block: Optional[str] = None,
              destination_prefix_list_id: Optional[str] = None,
              egress_only_gateway_id: Optional[str] = None,
              gateway_id: Optional[str] = None,
              instance_id: Optional[str] = None,
              local_gateway_id: Optional[str] = None,
              nat_gateway_id: Optional[str] = None,
              network_interface_id: Optional[str] = None,
              route_table_id: Optional[str] = None,
              transit_gateway_id: Optional[str] = None,
              vpc_peering_connection_id: Optional[str] = None,
              opts: Optional[InvokeOptions] = None) -> GetRouteResult
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.
CarrierGatewayId string
EC2 Carrier Gateway ID of the Route belonging to the Route Table.
DestinationCidrBlock string
CIDR block of the Route belonging to the Route Table.
DestinationIpv6CidrBlock string
IPv6 CIDR block of the Route belonging to the Route Table.
DestinationPrefixListId string
The ID of a managed prefix list destination of the Route belonging to the Route Table.
EgressOnlyGatewayId string
Egress Only Gateway ID of the Route belonging to the Route Table.
GatewayId string
Gateway ID of the Route belonging to the Route Table.
InstanceId string
Instance ID of the Route belonging to the Route Table.
LocalGatewayId string
Local Gateway ID of the Route belonging to the Route Table.
NatGatewayId string
NAT Gateway ID of the Route belonging to the Route Table.
NetworkInterfaceId string
Network Interface ID of the Route belonging to the Route Table.
TransitGatewayId string
EC2 Transit Gateway ID of the Route belonging to the Route Table.
VpcPeeringConnectionId string
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.
CarrierGatewayId string
EC2 Carrier Gateway ID of the Route belonging to the Route Table.
DestinationCidrBlock string
CIDR block of the Route belonging to the Route Table.
DestinationIpv6CidrBlock string
IPv6 CIDR block of the Route belonging to the Route Table.
DestinationPrefixListId string
The ID of a managed prefix list destination of the Route belonging to the Route Table.
EgressOnlyGatewayId string
Egress Only Gateway ID of the Route belonging to the Route Table.
GatewayId string
Gateway ID of the Route belonging to the Route Table.
InstanceId string
Instance ID of the Route belonging to the Route Table.
LocalGatewayId string
Local Gateway ID of the Route belonging to the Route Table.
NatGatewayId string
NAT Gateway ID of the Route belonging to the Route Table.
NetworkInterfaceId string
Network Interface ID of the Route belonging to the Route Table.
TransitGatewayId string
EC2 Transit Gateway ID of the Route belonging to the Route Table.
VpcPeeringConnectionId string
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.
carrierGatewayId string
EC2 Carrier Gateway ID of the Route belonging to the Route Table.
destinationCidrBlock string
CIDR block of the Route belonging to the Route Table.
destinationIpv6CidrBlock string
IPv6 CIDR block of the Route belonging to the Route Table.
destinationPrefixListId string
The ID of a managed prefix list destination of the Route belonging to the Route Table.
egressOnlyGatewayId string
Egress Only Gateway ID of the Route belonging to the Route Table.
gatewayId string
Gateway ID of the Route belonging to the Route Table.
instanceId string
Instance ID of the Route belonging to the Route Table.
localGatewayId string
Local Gateway ID of the Route belonging to the Route Table.
natGatewayId string
NAT Gateway ID of the Route belonging to the Route Table.
networkInterfaceId string
Network Interface ID of the Route belonging to the Route Table.
transitGatewayId string
EC2 Transit Gateway ID of the Route belonging to the Route Table.
vpcPeeringConnectionId string
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.
carrier_gateway_id str
EC2 Carrier Gateway ID of the Route belonging to the Route Table.
destination_cidr_block str
CIDR block of the Route belonging to the Route Table.
destination_ipv6_cidr_block str
IPv6 CIDR block of the Route belonging to the Route Table.
destination_prefix_list_id str
The ID of a managed prefix list destination of the Route belonging to the Route Table.
egress_only_gateway_id str
Egress Only Gateway ID of the Route belonging to the Route Table.
gateway_id str
Gateway ID of the Route belonging to the Route Table.
instance_id str
Instance ID of the Route belonging to the Route Table.
local_gateway_id str
Local Gateway ID of the Route belonging to the Route Table.
nat_gateway_id str
NAT Gateway ID of the Route belonging to the Route Table.
network_interface_id str
Network Interface ID of the Route belonging to the Route Table.
transit_gateway_id str
EC2 Transit Gateway ID of the Route belonging to the Route Table.
vpc_peering_connection_id str
VPC Peering Connection ID of the Route belonging to the Route Table.

getRoute Result

The following output properties are available:

CarrierGatewayId string
DestinationCidrBlock string
DestinationIpv6CidrBlock string
DestinationPrefixListId string
EgressOnlyGatewayId string
GatewayId string
Id string
The provider-assigned unique ID for this managed resource.
InstanceId string
LocalGatewayId string
NatGatewayId string
NetworkInterfaceId string
RouteTableId string
TransitGatewayId string
VpcPeeringConnectionId string
CarrierGatewayId string
DestinationCidrBlock string
DestinationIpv6CidrBlock string
DestinationPrefixListId string
EgressOnlyGatewayId string
GatewayId string
Id string
The provider-assigned unique ID for this managed resource.
InstanceId string
LocalGatewayId string
NatGatewayId string
NetworkInterfaceId string
RouteTableId string
TransitGatewayId string
VpcPeeringConnectionId string
carrierGatewayId string
destinationCidrBlock string
destinationIpv6CidrBlock string
destinationPrefixListId string
egressOnlyGatewayId string
gatewayId string
id string
The provider-assigned unique ID for this managed resource.
instanceId string
localGatewayId string
natGatewayId string
networkInterfaceId string
routeTableId string
transitGatewayId string
vpcPeeringConnectionId string

Package Details

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