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

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

Using getRouteTable

function getRouteTable(args: GetRouteTableArgs, opts?: InvokeOptions): Promise<GetRouteTableResult>
def get_route_table(filters: Optional[Sequence[GetRouteTableFilter]] = None,
                    gateway_id: Optional[str] = None,
                    route_table_id: Optional[str] = None,
                    subnet_id: Optional[str] = None,
                    tags: Optional[Mapping[str, str]] = None,
                    vpc_id: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetRouteTableResult
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<GetRouteTableFilter>
Configuration block. Detailed below.
GatewayId string
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
ID of the specific Route Table to retrieve.
SubnetId string
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
Tags Dictionary<string, string>
Map of tags, each pair of which must exactly match a pair on the desired Route Table.
VpcId string
ID of the VPC that the desired Route Table belongs to.
Filters []GetRouteTableFilter
Configuration block. Detailed below.
GatewayId string
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
ID of the specific Route Table to retrieve.
SubnetId string
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
Tags map[string]string
Map of tags, each pair of which must exactly match a pair on the desired Route Table.
VpcId string
ID of the VPC that the desired Route Table belongs to.
filters GetRouteTableFilter[]
Configuration block. Detailed below.
gatewayId string
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
ID of the specific Route Table to retrieve.
subnetId string
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
tags {[key: string]: string}
Map of tags, each pair of which must exactly match a pair on the desired Route Table.
vpcId string
ID of the VPC that the desired Route Table belongs to.
filters Sequence[GetRouteTableFilter]
Configuration block. Detailed below.
gateway_id str
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
ID of the specific Route Table to retrieve.
subnet_id str
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
tags Mapping[str, str]
Map of tags, each pair of which must exactly match a pair on the desired Route Table.
vpc_id str
ID of the VPC that the desired Route Table belongs to.

getRouteTable Result

The following output properties are available:

Arn string
ARN of the route table.
Associations List<GetRouteTableAssociation>
List of associations with attributes detailed below.
GatewayId string
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
ID of the AWS account that owns the route table.
RouteTableId string
Route Table ID.
Routes List<GetRouteTableRoute>
List of routes with attributes detailed below.
SubnetId string
Subnet ID. Only set when associated with a subnet.
Tags Dictionary<string, string>
VpcId string
Filters List<GetRouteTableFilter>
Arn string
ARN of the route table.
Associations []GetRouteTableAssociationType
List of associations with attributes detailed below.
GatewayId string
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
ID of the AWS account that owns the route table.
RouteTableId string
Route Table ID.
Routes []GetRouteTableRoute
List of routes with attributes detailed below.
SubnetId string
Subnet ID. Only set when associated with a subnet.
Tags map[string]string
VpcId string
Filters []GetRouteTableFilter
arn string
ARN of the route table.
associations GetRouteTableAssociation[]
List of associations with attributes detailed below.
gatewayId string
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
ID of the AWS account that owns the route table.
routeTableId string
Route Table ID.
routes GetRouteTableRoute[]
List of routes with attributes detailed below.
subnetId string
Subnet ID. Only set when associated with a subnet.
tags {[key: string]: string}
vpcId string
filters GetRouteTableFilter[]
arn str
ARN of the route table.
associations Sequence[GetRouteTableAssociation]
List of associations with attributes detailed below.
gateway_id str
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
ID of the AWS account that owns the route table.
route_table_id str
Route Table ID.
routes Sequence[GetRouteTableRoute]
List of routes with attributes detailed below.
subnet_id str
Subnet ID. Only set when associated with a subnet.
tags Mapping[str, str]
vpc_id str
filters Sequence[GetRouteTableFilter]

Supporting Types

GetRouteTableAssociation

GatewayId string
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
Whether the association is due to the main route table.
RouteTableAssociationId string
Association ID.
RouteTableId string
ID of the specific Route Table to retrieve.
SubnetId string
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
GatewayId string
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
Whether the association is due to the main route table.
RouteTableAssociationId string
Association ID.
RouteTableId string
ID of the specific Route Table to retrieve.
SubnetId string
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
gatewayId string
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
Whether the association is due to the main route table.
routeTableAssociationId string
Association ID.
routeTableId string
ID of the specific Route Table to retrieve.
subnetId string
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
gateway_id str
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
Whether the association is due to the main route table.
route_table_association_id str
Association ID.
route_table_id str
ID of the specific Route Table to retrieve.
subnet_id str
ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).

GetRouteTableFilter

Name string
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
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
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
Name of the field to filter by, as defined by the underlying AWS API.
values Sequence[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

CarrierGatewayId string
ID of the Carrier Gateway.
CidrBlock string
CIDR block of the route.
DestinationPrefixListId string
The ID of a managed prefix list destination of the route.
EgressOnlyGatewayId string
ID of the Egress Only Internet Gateway.
GatewayId string
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
EC2 instance ID.
Ipv6CidrBlock string
IPv6 CIDR block of the route.
LocalGatewayId string
Local Gateway ID.
NatGatewayId string
NAT Gateway ID.
NetworkInterfaceId string
ID of the elastic network interface (eni) to use.
TransitGatewayId string
EC2 Transit Gateway ID.
VpcEndpointId string
VPC Endpoint ID.
VpcPeeringConnectionId string
VPC Peering ID.
CarrierGatewayId string
ID of the Carrier Gateway.
CidrBlock string
CIDR block of the route.
DestinationPrefixListId string
The ID of a managed prefix list destination of the route.
EgressOnlyGatewayId string
ID of the Egress Only Internet Gateway.
GatewayId string
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
EC2 instance ID.
Ipv6CidrBlock string
IPv6 CIDR block of the route.
LocalGatewayId string
Local Gateway ID.
NatGatewayId string
NAT Gateway ID.
NetworkInterfaceId string
ID of the elastic network interface (eni) to use.
TransitGatewayId string
EC2 Transit Gateway ID.
VpcEndpointId string
VPC Endpoint ID.
VpcPeeringConnectionId string
VPC Peering ID.
carrierGatewayId string
ID of the Carrier Gateway.
cidrBlock string
CIDR block of the route.
destinationPrefixListId string
The ID of a managed prefix list destination of the route.
egressOnlyGatewayId string
ID of the Egress Only Internet Gateway.
gatewayId string
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
EC2 instance ID.
ipv6CidrBlock string
IPv6 CIDR block of the route.
localGatewayId string
Local Gateway ID.
natGatewayId string
NAT Gateway ID.
networkInterfaceId string
ID of the elastic network interface (eni) to use.
transitGatewayId string
EC2 Transit Gateway ID.
vpcEndpointId string
VPC Endpoint ID.
vpcPeeringConnectionId string
VPC Peering ID.
carrier_gateway_id str
ID of the Carrier Gateway.
cidr_block str
CIDR block of the route.
destination_prefix_list_id str
The ID of a managed prefix list destination of the route.
egress_only_gateway_id str
ID of the Egress Only Internet Gateway.
gateway_id str
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
EC2 instance ID.
ipv6_cidr_block str
IPv6 CIDR block of the route.
local_gateway_id str
Local Gateway ID.
nat_gateway_id str
NAT Gateway ID.
network_interface_id str
ID of the elastic network interface (eni) to use.
transit_gateway_id str
EC2 Transit Gateway ID.
vpc_endpoint_id str
VPC Endpoint ID.
vpc_peering_connection_id str
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.