1. Packages
  2. AWS Classic
  3. API Docs
  4. ec2
  5. getRoute

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.ec2.getRoute

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    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

    The following example shows how one might use a CIDR value to find a network interface id and use this to create a data source of that network interface.

    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: selectedAwsRouteTable.id,
        destinationCidrBlock: "10.0.1.0/24",
    });
    const interface = route.then(route => aws.ec2.getNetworkInterface({
        id: route.networkInterfaceId,
    }));
    
    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=selected_aws_route_table["id"],
        destination_cidr_block="10.0.1.0/24")
    interface = aws.ec2.get_network_interface(id=route.network_interface_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/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")
    		_, err := ec2.LookupRouteTable(ctx, &ec2.LookupRouteTableArgs{
    			SubnetId: pulumi.StringRef(subnetId),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		route, err := ec2.LookupRoute(ctx, &ec2.LookupRouteArgs{
    			RouteTableId:         selectedAwsRouteTable.Id,
    			DestinationCidrBlock: pulumi.StringRef("10.0.1.0/24"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = ec2.LookupNetworkInterface(ctx, &ec2.LookupNetworkInterfaceArgs{
    			Id: pulumi.StringRef(route.NetworkInterfaceId),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var subnetId = config.RequireObject<dynamic>("subnetId");
        var selected = Aws.Ec2.GetRouteTable.Invoke(new()
        {
            SubnetId = subnetId,
        });
    
        var route = Aws.Ec2.GetRoute.Invoke(new()
        {
            RouteTableId = selectedAwsRouteTable.Id,
            DestinationCidrBlock = "10.0.1.0/24",
        });
    
        var @interface = Aws.Ec2.GetNetworkInterface.Invoke(new()
        {
            Id = route.Apply(getRouteResult => getRouteResult.NetworkInterfaceId),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetRouteTableArgs;
    import com.pulumi.aws.ec2.inputs.GetRouteArgs;
    import com.pulumi.aws.ec2.inputs.GetNetworkInterfaceArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var config = ctx.config();
            final var subnetId = config.get("subnetId");
            final var selected = Ec2Functions.getRouteTable(GetRouteTableArgs.builder()
                .subnetId(subnetId)
                .build());
    
            final var route = Ec2Functions.getRoute(GetRouteArgs.builder()
                .routeTableId(selectedAwsRouteTable.id())
                .destinationCidrBlock("10.0.1.0/24")
                .build());
    
            final var interface = Ec2Functions.getNetworkInterface(GetNetworkInterfaceArgs.builder()
                .id(route.applyValue(getRouteResult -> getRouteResult.networkInterfaceId()))
                .build());
    
        }
    }
    
    configuration:
      subnetId:
        type: dynamic
    variables:
      selected:
        fn::invoke:
          Function: aws:ec2:getRouteTable
          Arguments:
            subnetId: ${subnetId}
      route:
        fn::invoke:
          Function: aws:ec2:getRoute
          Arguments:
            routeTableId: ${selectedAwsRouteTable.id}
            destinationCidrBlock: 10.0.1.0/24
      interface:
        fn::invoke:
          Function: aws:ec2:getNetworkInterface
          Arguments:
            id: ${route.networkInterfaceId}
    

    Using getRoute

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getRoute(args: GetRouteArgs, opts?: InvokeOptions): Promise<GetRouteResult>
    function getRouteOutput(args: GetRouteOutputArgs, opts?: InvokeOptions): Output<GetRouteResult>
    def get_route(carrier_gateway_id: Optional[str] = None,
                  core_network_arn: 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
    def get_route_output(carrier_gateway_id: Optional[pulumi.Input[str]] = None,
                  core_network_arn: Optional[pulumi.Input[str]] = None,
                  destination_cidr_block: Optional[pulumi.Input[str]] = None,
                  destination_ipv6_cidr_block: Optional[pulumi.Input[str]] = None,
                  destination_prefix_list_id: Optional[pulumi.Input[str]] = None,
                  egress_only_gateway_id: Optional[pulumi.Input[str]] = None,
                  gateway_id: Optional[pulumi.Input[str]] = None,
                  instance_id: Optional[pulumi.Input[str]] = None,
                  local_gateway_id: Optional[pulumi.Input[str]] = None,
                  nat_gateway_id: Optional[pulumi.Input[str]] = None,
                  network_interface_id: Optional[pulumi.Input[str]] = None,
                  route_table_id: Optional[pulumi.Input[str]] = None,
                  transit_gateway_id: Optional[pulumi.Input[str]] = None,
                  vpc_peering_connection_id: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetRouteResult]
    func LookupRoute(ctx *Context, args *LookupRouteArgs, opts ...InvokeOption) (*LookupRouteResult, error)
    func LookupRouteOutput(ctx *Context, args *LookupRouteOutputArgs, opts ...InvokeOption) LookupRouteResultOutput

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

    public static class GetRoute 
    {
        public static Task<GetRouteResult> InvokeAsync(GetRouteArgs args, InvokeOptions? opts = null)
        public static Output<GetRouteResult> Invoke(GetRouteInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRouteResult> getRoute(GetRouteArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:ec2/getRoute:getRoute
      arguments:
        # arguments dictionary

    The following arguments are supported:

    RouteTableId string

    ID of the specific Route Table containing the Route entry.

    The following arguments are optional:

    CarrierGatewayId string
    EC2 Carrier Gateway ID of the Route belonging to the Route Table.
    CoreNetworkArn string
    Core network ARN 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
    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

    ID of the specific Route Table containing the Route entry.

    The following arguments are optional:

    CarrierGatewayId string
    EC2 Carrier Gateway ID of the Route belonging to the Route Table.
    CoreNetworkArn string
    Core network ARN 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
    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

    ID of the specific Route Table containing the Route entry.

    The following arguments are optional:

    carrierGatewayId String
    EC2 Carrier Gateway ID of the Route belonging to the Route Table.
    coreNetworkArn String
    Core network ARN 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
    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

    ID of the specific Route Table containing the Route entry.

    The following arguments are optional:

    carrierGatewayId string
    EC2 Carrier Gateway ID of the Route belonging to the Route Table.
    coreNetworkArn string
    Core network ARN 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
    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

    ID of the specific Route Table containing the Route entry.

    The following arguments are optional:

    carrier_gateway_id str
    EC2 Carrier Gateway ID of the Route belonging to the Route Table.
    core_network_arn str
    Core network ARN 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
    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.
    routeTableId String

    ID of the specific Route Table containing the Route entry.

    The following arguments are optional:

    carrierGatewayId String
    EC2 Carrier Gateway ID of the Route belonging to the Route Table.
    coreNetworkArn String
    Core network ARN 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
    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.

    getRoute Result

    The following output properties are available:

    CarrierGatewayId string
    CoreNetworkArn 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
    CoreNetworkArn 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
    coreNetworkArn 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
    coreNetworkArn 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
    coreNetworkArn 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
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi