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
LookupRoutein the Go SDK.
public static class GetRoute {
public static Task<GetRouteResult> InvokeAsync(GetRouteArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Route
Table stringId The id of the specific Route Table containing the Route entry.
- Destination
Cidr stringBlock The CIDR block of the Route belonging to the Route Table.
- Destination
Ipv6Cidr stringBlock The IPv6 CIDR block of the Route belonging to the Route Table.
- Egress
Only stringGateway Id The Egress Only Gateway ID of the Route belonging to the Route Table.
- Gateway
Id string The Gateway ID of the Route belonging to the Route Table.
- Instance
Id string The Instance ID of the Route belonging to the Route Table.
- Nat
Gateway stringId The NAT Gateway ID of the Route belonging to the Route Table.
- Network
Interface stringId The Network Interface ID of the Route belonging to the Route Table.
- Transit
Gateway stringId The EC2 Transit Gateway ID of the Route belonging to the Route Table.
- Vpc
Peering stringConnection Id The VPC Peering Connection ID of the Route belonging to the Route Table.
- Route
Table stringId The id of the specific Route Table containing the Route entry.
- Destination
Cidr stringBlock The CIDR block of the Route belonging to the Route Table.
- Destination
Ipv6Cidr stringBlock The IPv6 CIDR block of the Route belonging to the Route Table.
- Egress
Only stringGateway Id The Egress Only Gateway ID of the Route belonging to the Route Table.
- Gateway
Id string The Gateway ID of the Route belonging to the Route Table.
- Instance
Id string The Instance ID of the Route belonging to the Route Table.
- Nat
Gateway stringId The NAT Gateway ID of the Route belonging to the Route Table.
- Network
Interface stringId The Network Interface ID of the Route belonging to the Route Table.
- Transit
Gateway stringId The EC2 Transit Gateway ID of the Route belonging to the Route Table.
- Vpc
Peering stringConnection Id The VPC Peering Connection ID of the Route belonging to the Route Table.
- route
Table stringId The id of the specific Route Table containing the Route entry.
- destination
Cidr stringBlock The CIDR block of the Route belonging to the Route Table.
- destination
Ipv6Cidr stringBlock The IPv6 CIDR block of the Route belonging to the Route Table.
- egress
Only stringGateway Id The Egress Only Gateway ID of the Route belonging to the Route Table.
- gateway
Id string The Gateway ID of the Route belonging to the Route Table.
- instance
Id string The Instance ID of the Route belonging to the Route Table.
- nat
Gateway stringId The NAT Gateway ID of the Route belonging to the Route Table.
- network
Interface stringId The Network Interface ID of the Route belonging to the Route Table.
- transit
Gateway stringId The EC2 Transit Gateway ID of the Route belonging to the Route Table.
- vpc
Peering stringConnection Id The VPC Peering Connection ID of the Route belonging to the Route Table.
- route_
table_ strid The id of the specific Route Table containing the Route entry.
- destination_
cidr_ strblock The CIDR block of the Route belonging to the Route Table.
- destination_
ipv6_ strcidr_ block The IPv6 CIDR block of the Route belonging to the Route Table.
- egress_
only_ strgateway_ id 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_ strid The NAT Gateway ID of the Route belonging to the Route Table.
- network_
interface_ strid The Network Interface ID of the Route belonging to the Route Table.
- transit_
gateway_ strid The EC2 Transit Gateway ID of the Route belonging to the Route Table.
- vpc_
peering_ strconnection_ id The VPC Peering Connection ID of the Route belonging to the Route Table.
GetRoute Result
The following output properties are available:
- Destination
Cidr stringBlock - Destination
Ipv6Cidr stringBlock - Egress
Only stringGateway Id - Gateway
Id string - Id string
The provider-assigned unique ID for this managed resource.
- Instance
Id string - Nat
Gateway stringId - Network
Interface stringId - Route
Table stringId - Transit
Gateway stringId - Vpc
Peering stringConnection Id
- Destination
Cidr stringBlock - Destination
Ipv6Cidr stringBlock - Egress
Only stringGateway Id - Gateway
Id string - Id string
The provider-assigned unique ID for this managed resource.
- Instance
Id string - Nat
Gateway stringId - Network
Interface stringId - Route
Table stringId - Transit
Gateway stringId - Vpc
Peering stringConnection Id
- destination
Cidr stringBlock - destination
Ipv6Cidr stringBlock - egress
Only stringGateway Id - gateway
Id string - id string
The provider-assigned unique ID for this managed resource.
- instance
Id string - nat
Gateway stringId - network
Interface stringId - route
Table stringId - transit
Gateway stringId - vpc
Peering stringConnection Id
- destination_
cidr_ strblock - destination_
ipv6_ strcidr_ block - egress_
only_ strgateway_ id - gateway_
id str - id str
The provider-assigned unique ID for this managed resource.
- instance_
id str - nat_
gateway_ strid - network_
interface_ strid - route_
table_ strid - transit_
gateway_ strid - vpc_
peering_ strconnection_ id
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.