Try AWS Native preview for resources not in the classic version.
aws.ec2.getRoute
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
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:
- Route
Table stringId ID of the specific Route Table containing the Route entry.
The following arguments are optional:
- Carrier
Gateway stringId - EC2 Carrier Gateway ID of the Route belonging to the Route Table.
- Core
Network stringArn - Core network ARN of the Route belonging to the Route Table.
- Destination
Cidr stringBlock - CIDR block of the Route belonging to the Route Table.
- Destination
Ipv6Cidr stringBlock - IPv6 CIDR block of the Route belonging to the Route Table.
- Destination
Prefix stringList Id - ID of a managed prefix list destination of the Route belonging to the Route Table.
- Egress
Only stringGateway Id - Egress Only Gateway ID of the Route belonging to the Route Table.
- Gateway
Id string - Gateway ID of the Route belonging to the Route Table.
- Instance
Id string - Instance ID of the Route belonging to the Route Table.
- Local
Gateway stringId - Local Gateway ID of the Route belonging to the Route Table.
- Nat
Gateway stringId - NAT Gateway ID of the Route belonging to the Route Table.
- Network
Interface stringId - Network Interface ID of the Route belonging to the Route Table.
- Transit
Gateway stringId - EC2 Transit Gateway ID of the Route belonging to the Route Table.
- Vpc
Peering stringConnection Id - VPC Peering Connection ID of the Route belonging to the Route Table.
- Route
Table stringId ID of the specific Route Table containing the Route entry.
The following arguments are optional:
- Carrier
Gateway stringId - EC2 Carrier Gateway ID of the Route belonging to the Route Table.
- Core
Network stringArn - Core network ARN of the Route belonging to the Route Table.
- Destination
Cidr stringBlock - CIDR block of the Route belonging to the Route Table.
- Destination
Ipv6Cidr stringBlock - IPv6 CIDR block of the Route belonging to the Route Table.
- Destination
Prefix stringList Id - ID of a managed prefix list destination of the Route belonging to the Route Table.
- Egress
Only stringGateway Id - Egress Only Gateway ID of the Route belonging to the Route Table.
- Gateway
Id string - Gateway ID of the Route belonging to the Route Table.
- Instance
Id string - Instance ID of the Route belonging to the Route Table.
- Local
Gateway stringId - Local Gateway ID of the Route belonging to the Route Table.
- Nat
Gateway stringId - NAT Gateway ID of the Route belonging to the Route Table.
- Network
Interface stringId - Network Interface ID of the Route belonging to the Route Table.
- Transit
Gateway stringId - EC2 Transit Gateway ID of the Route belonging to the Route Table.
- Vpc
Peering stringConnection Id - VPC Peering Connection ID of the Route belonging to the Route Table.
- route
Table StringId ID of the specific Route Table containing the Route entry.
The following arguments are optional:
- carrier
Gateway StringId - EC2 Carrier Gateway ID of the Route belonging to the Route Table.
- core
Network StringArn - Core network ARN of the Route belonging to the Route Table.
- destination
Cidr StringBlock - CIDR block of the Route belonging to the Route Table.
- destination
Ipv6Cidr StringBlock - IPv6 CIDR block of the Route belonging to the Route Table.
- destination
Prefix StringList Id - ID of a managed prefix list destination of the Route belonging to the Route Table.
- egress
Only StringGateway Id - Egress Only Gateway ID of the Route belonging to the Route Table.
- gateway
Id String - Gateway ID of the Route belonging to the Route Table.
- instance
Id String - Instance ID of the Route belonging to the Route Table.
- local
Gateway StringId - Local Gateway ID of the Route belonging to the Route Table.
- nat
Gateway StringId - NAT Gateway ID of the Route belonging to the Route Table.
- network
Interface StringId - Network Interface ID of the Route belonging to the Route Table.
- transit
Gateway StringId - EC2 Transit Gateway ID of the Route belonging to the Route Table.
- vpc
Peering StringConnection Id - VPC Peering Connection ID of the Route belonging to the Route Table.
- route
Table stringId ID of the specific Route Table containing the Route entry.
The following arguments are optional:
- carrier
Gateway stringId - EC2 Carrier Gateway ID of the Route belonging to the Route Table.
- core
Network stringArn - Core network ARN of the Route belonging to the Route Table.
- destination
Cidr stringBlock - CIDR block of the Route belonging to the Route Table.
- destination
Ipv6Cidr stringBlock - IPv6 CIDR block of the Route belonging to the Route Table.
- destination
Prefix stringList Id - ID of a managed prefix list destination of the Route belonging to the Route Table.
- egress
Only stringGateway Id - Egress Only Gateway ID of the Route belonging to the Route Table.
- gateway
Id string - Gateway ID of the Route belonging to the Route Table.
- instance
Id string - Instance ID of the Route belonging to the Route Table.
- local
Gateway stringId - Local Gateway ID of the Route belonging to the Route Table.
- nat
Gateway stringId - NAT Gateway ID of the Route belonging to the Route Table.
- network
Interface stringId - Network Interface ID of the Route belonging to the Route Table.
- transit
Gateway stringId - EC2 Transit Gateway ID of the Route belonging to the Route Table.
- vpc
Peering stringConnection Id - VPC Peering Connection ID of the Route belonging to the Route Table.
- route_
table_ strid ID of the specific Route Table containing the Route entry.
The following arguments are optional:
- carrier_
gateway_ strid - EC2 Carrier Gateway ID of the Route belonging to the Route Table.
- core_
network_ strarn - Core network ARN of the Route belonging to the Route Table.
- destination_
cidr_ strblock - CIDR block of the Route belonging to the Route Table.
- destination_
ipv6_ strcidr_ block - IPv6 CIDR block of the Route belonging to the Route Table.
- destination_
prefix_ strlist_ id - ID of a managed prefix list destination of the Route belonging to the Route Table.
- egress_
only_ strgateway_ id - 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_ strid - Local Gateway ID of the Route belonging to the Route Table.
- nat_
gateway_ strid - NAT Gateway ID of the Route belonging to the Route Table.
- network_
interface_ strid - Network Interface ID of the Route belonging to the Route Table.
- transit_
gateway_ strid - EC2 Transit Gateway ID of the Route belonging to the Route Table.
- vpc_
peering_ strconnection_ id - VPC Peering Connection ID of the Route belonging to the Route Table.
- route
Table StringId ID of the specific Route Table containing the Route entry.
The following arguments are optional:
- carrier
Gateway StringId - EC2 Carrier Gateway ID of the Route belonging to the Route Table.
- core
Network StringArn - Core network ARN of the Route belonging to the Route Table.
- destination
Cidr StringBlock - CIDR block of the Route belonging to the Route Table.
- destination
Ipv6Cidr StringBlock - IPv6 CIDR block of the Route belonging to the Route Table.
- destination
Prefix StringList Id - ID of a managed prefix list destination of the Route belonging to the Route Table.
- egress
Only StringGateway Id - Egress Only Gateway ID of the Route belonging to the Route Table.
- gateway
Id String - Gateway ID of the Route belonging to the Route Table.
- instance
Id String - Instance ID of the Route belonging to the Route Table.
- local
Gateway StringId - Local Gateway ID of the Route belonging to the Route Table.
- nat
Gateway StringId - NAT Gateway ID of the Route belonging to the Route Table.
- network
Interface StringId - Network Interface ID of the Route belonging to the Route Table.
- transit
Gateway StringId - EC2 Transit Gateway ID of the Route belonging to the Route Table.
- vpc
Peering StringConnection Id - VPC Peering Connection ID of the Route belonging to the Route Table.
getRoute Result
The following output properties are available:
- Carrier
Gateway stringId - Core
Network stringArn - Destination
Cidr stringBlock - Destination
Ipv6Cidr stringBlock - Destination
Prefix stringList Id - Egress
Only stringGateway Id - Gateway
Id string - Id string
- The provider-assigned unique ID for this managed resource.
- Instance
Id string - Local
Gateway stringId - Nat
Gateway stringId - Network
Interface stringId - Route
Table stringId - Transit
Gateway stringId - Vpc
Peering stringConnection Id
- Carrier
Gateway stringId - Core
Network stringArn - Destination
Cidr stringBlock - Destination
Ipv6Cidr stringBlock - Destination
Prefix stringList Id - Egress
Only stringGateway Id - Gateway
Id string - Id string
- The provider-assigned unique ID for this managed resource.
- Instance
Id string - Local
Gateway stringId - Nat
Gateway stringId - Network
Interface stringId - Route
Table stringId - Transit
Gateway stringId - Vpc
Peering stringConnection Id
- carrier
Gateway StringId - core
Network StringArn - destination
Cidr StringBlock - destination
Ipv6Cidr StringBlock - destination
Prefix StringList Id - egress
Only StringGateway Id - gateway
Id String - id String
- The provider-assigned unique ID for this managed resource.
- instance
Id String - local
Gateway StringId - nat
Gateway StringId - network
Interface StringId - route
Table StringId - transit
Gateway StringId - vpc
Peering StringConnection Id
- carrier
Gateway stringId - core
Network stringArn - destination
Cidr stringBlock - destination
Ipv6Cidr stringBlock - destination
Prefix stringList Id - egress
Only stringGateway Id - gateway
Id string - id string
- The provider-assigned unique ID for this managed resource.
- instance
Id string - local
Gateway stringId - nat
Gateway stringId - network
Interface stringId - route
Table stringId - transit
Gateway stringId - vpc
Peering stringConnection Id
- carrier_
gateway_ strid - core_
network_ strarn - destination_
cidr_ strblock - destination_
ipv6_ strcidr_ block - destination_
prefix_ strlist_ id - egress_
only_ strgateway_ id - gateway_
id str - id str
- The provider-assigned unique ID for this managed resource.
- instance_
id str - local_
gateway_ strid - nat_
gateway_ strid - network_
interface_ strid - route_
table_ strid - transit_
gateway_ strid - vpc_
peering_ strconnection_ id
- carrier
Gateway StringId - core
Network StringArn - destination
Cidr StringBlock - destination
Ipv6Cidr StringBlock - destination
Prefix StringList Id - egress
Only StringGateway Id - gateway
Id String - id String
- The provider-assigned unique ID for this managed resource.
- instance
Id String - local
Gateway StringId - nat
Gateway StringId - network
Interface StringId - route
Table StringId - transit
Gateway StringId - vpc
Peering StringConnection Id
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.