GetRouteTable

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

This resource can prove useful when a module accepts a Subnet id as an input variable and needs to, for example, add a route in the Route Table.

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 = new Aws.Ec2.Route("route", new Aws.Ec2.RouteArgs
        {
            DestinationCidrBlock = "10.0.1.0/22",
            RouteTableId = selected.Apply(selected => selected.Id),
            VpcPeeringConnectionId = "pcx-45ff3dc1",
        });
    }

}
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
        selected, err := ec2.LookupRouteTable(ctx, &ec2.LookupRouteTableArgs{
            SubnetId: &opt0,
        }, nil)
        if err != nil {
            return err
        }
        _, err = ec2.NewRoute(ctx, "route", &ec2.RouteArgs{
            DestinationCidrBlock:   pulumi.String("10.0.1.0/22"),
            RouteTableId:           pulumi.String(selected.Id),
            VpcPeeringConnectionId: pulumi.String("pcx-45ff3dc1"),
        })
        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.Route("route",
    destination_cidr_block="10.0.1.0/22",
    route_table_id=selected.id,
    vpc_peering_connection_id="pcx-45ff3dc1")
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 = new aws.ec2.Route("route", {
    destinationCidrBlock: "10.0.1.0/22",
    routeTableId: selected.id,
    vpcPeeringConnectionId: "pcx-45ff3dc1",
});

Using GetRouteTable

function getRouteTable(args: GetRouteTableArgs, opts?: InvokeOptions): Promise<GetRouteTableResult>
function  get_route_table(filters=None, gateway_id=None, route_table_id=None, subnet_id=None, tags=None, vpc_id=None, opts=None)
func LookupRouteTable(ctx *Context, args *LookupRouteTableArgs, opts ...InvokeOption) (*LookupRouteTableResult, error)

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

public static class GetRouteTable {
    public static Task<GetRouteTableResult> InvokeAsync(GetRouteTableArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<GetRouteTableFilterArgs>

Custom filter block as described below.

GatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

RouteTableId string

The id of the specific Route Table to retrieve.

SubnetId string

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

Tags Dictionary<string, string>

A map of tags, each pair of which must exactly match a pair on the desired Route Table.

VpcId string

The id of the VPC that the desired Route Table belongs to.

Filters []GetRouteTableFilter

Custom filter block as described below.

GatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

RouteTableId string

The id of the specific Route Table to retrieve.

SubnetId string

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

Tags map[string]string

A map of tags, each pair of which must exactly match a pair on the desired Route Table.

VpcId string

The id of the VPC that the desired Route Table belongs to.

filters GetRouteTableFilter[]

Custom filter block as described below.

gatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

routeTableId string

The id of the specific Route Table to retrieve.

subnetId string

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

tags {[key: string]: string}

A map of tags, each pair of which must exactly match a pair on the desired Route Table.

vpcId string

The id of the VPC that the desired Route Table belongs to.

filters List[GetRouteTableFilter]

Custom filter block as described below.

gateway_id str

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

route_table_id str

The id of the specific Route Table to retrieve.

subnet_id str

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

tags Dict[str, str]

A map of tags, each pair of which must exactly match a pair on the desired Route Table.

vpc_id str

The id of the VPC that the desired Route Table belongs to.

GetRouteTable Result

The following output properties are available:

Associations List<GetRouteTableAssociation>
GatewayId string

The Gateway ID. Only set when associated with an Internet Gateway or Virtual Private Gateway.

Id string

The provider-assigned unique ID for this managed resource.

OwnerId string

The ID of the AWS account that owns the route table

RouteTableId string

The Route Table ID.

Routes List<GetRouteTableRoute>
SubnetId string

The Subnet ID. Only set when associated with a Subnet.

Tags Dictionary<string, string>
VpcId string
Filters List<GetRouteTableFilter>
Associations []GetRouteTableAssociationType
GatewayId string

The Gateway ID. Only set when associated with an Internet Gateway or Virtual Private Gateway.

Id string

The provider-assigned unique ID for this managed resource.

OwnerId string

The ID of the AWS account that owns the route table

RouteTableId string

The Route Table ID.

Routes []GetRouteTableRoute
SubnetId string

The Subnet ID. Only set when associated with a Subnet.

Tags map[string]string
VpcId string
Filters []GetRouteTableFilter
associations GetRouteTableAssociation[]
gatewayId string

The Gateway ID. Only set when associated with an Internet Gateway or Virtual Private Gateway.

id string

The provider-assigned unique ID for this managed resource.

ownerId string

The ID of the AWS account that owns the route table

routeTableId string

The Route Table ID.

routes GetRouteTableRoute[]
subnetId string

The Subnet ID. Only set when associated with a Subnet.

tags {[key: string]: string}
vpcId string
filters GetRouteTableFilter[]
associations List[GetRouteTableAssociation]
gateway_id str

The Gateway ID. Only set when associated with an Internet Gateway or Virtual Private Gateway.

id str

The provider-assigned unique ID for this managed resource.

owner_id str

The ID of the AWS account that owns the route table

route_table_id str

The Route Table ID.

routes List[GetRouteTableRoute]
subnet_id str

The Subnet ID. Only set when associated with a Subnet.

tags Dict[str, str]
vpc_id str
filters List[GetRouteTableFilter]

Supporting Types

GetRouteTableAssociation

See the output API doc for this type.

See the output API doc for this type.

See the output API doc for this type.

GatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

Main bool

If the Association due to the Main Route Table.

RouteTableAssociationId string

The Association ID.

RouteTableId string

The id of the specific Route Table to retrieve.

SubnetId string

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

GatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

Main bool

If the Association due to the Main Route Table.

RouteTableAssociationId string

The Association ID.

RouteTableId string

The id of the specific Route Table to retrieve.

SubnetId string

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

gatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

main boolean

If the Association due to the Main Route Table.

routeTableAssociationId string

The Association ID.

routeTableId string

The id of the specific Route Table to retrieve.

subnetId string

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

gateway_id str

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

main bool

If the Association due to the Main Route Table.

routeTableAssociationId str

The Association ID.

route_table_id str

The id of the specific Route Table to retrieve.

subnet_id str

The id of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

GetRouteTableFilter

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Name string

The name of the field to filter by, as defined by the underlying AWS API.

Values List<string>

Set of values that are accepted for the given field. A Route Table will be selected if any one of the given values matches.

Name string

The name of the field to filter by, as defined by the underlying AWS API.

Values []string

Set of values that are accepted for the given field. A Route Table will be selected if any one of the given values matches.

name string

The name of the field to filter by, as defined by the underlying AWS API.

values string[]

Set of values that are accepted for the given field. A Route Table will be selected if any one of the given values matches.

name str

The name of the field to filter by, as defined by the underlying AWS API.

values List[str]

Set of values that are accepted for the given field. A Route Table will be selected if any one of the given values matches.

GetRouteTableRoute

See the output API doc for this type.

See the output API doc for this type.

See the output API doc for this type.

CidrBlock string

The CIDR block of the route.

EgressOnlyGatewayId string

The ID of the Egress Only Internet Gateway.

GatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

InstanceId string

The EC2 instance ID.

Ipv6CidrBlock string

The IPv6 CIDR block of the route.

NatGatewayId string

The NAT Gateway ID.

NetworkInterfaceId string

The ID of the elastic network interface (eni) to use.

TransitGatewayId string

The EC2 Transit Gateway ID.

VpcPeeringConnectionId string

The VPC Peering ID.

CidrBlock string

The CIDR block of the route.

EgressOnlyGatewayId string

The ID of the Egress Only Internet Gateway.

GatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

InstanceId string

The EC2 instance ID.

Ipv6CidrBlock string

The IPv6 CIDR block of the route.

NatGatewayId string

The NAT Gateway ID.

NetworkInterfaceId string

The ID of the elastic network interface (eni) to use.

TransitGatewayId string

The EC2 Transit Gateway ID.

VpcPeeringConnectionId string

The VPC Peering ID.

cidrBlock string

The CIDR block of the route.

egressOnlyGatewayId string

The ID of the Egress Only Internet Gateway.

gatewayId string

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

instanceId string

The EC2 instance ID.

ipv6CidrBlock string

The IPv6 CIDR block of the route.

natGatewayId string

The NAT Gateway ID.

networkInterfaceId string

The ID of the elastic network interface (eni) to use.

transitGatewayId string

The EC2 Transit Gateway ID.

vpcPeeringConnectionId string

The VPC Peering ID.

cidr_block str

The CIDR block of the route.

egress_only_gateway_id str

The ID of the Egress Only Internet Gateway.

gateway_id str

The id of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter).

instance_id str

The EC2 instance ID.

ipv6_cidr_block str

The IPv6 CIDR block of the route.

nat_gateway_id str

The NAT Gateway ID.

network_interface_id str

The ID of the elastic network interface (eni) to use.

transit_gateway_id str

The EC2 Transit Gateway ID.

vpc_peering_connection_id str

The VPC Peering ID.

Package Details

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