getRouteTables

This resource can be useful for getting back a list of route table ids to be referenced elsewhere.

Example Usage

using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var dict = Output.Create(Initialize());
    }

    private async Task<IDictionary<string, Output<string>>> Initialize()
    {
        var rts = await Aws.Ec2.GetRouteTables.InvokeAsync(new Aws.Ec2.GetRouteTablesArgs
        {
            VpcId = @var.Vpc_id,
            Filters = 
            {
                new Aws.Ec2.Inputs.GetRouteTablesFilterArgs
                {
                    Name = "tag:kubernetes.io/kops/role",
                    Values = 
                    {
                        "private*",
                    },
                },
            },
        });
        var route = new List<Aws.Ec2.Route>();
        for (var rangeIndex = 0; rangeIndex < rts.Ids.Length; rangeIndex++)
        {
            var range = new { Value = rangeIndex };
            route.Add(new Aws.Ec2.Route($"route-{range.Value}", new Aws.Ec2.RouteArgs
            {
                RouteTableId = rts.Ids[range.Value],
                DestinationCidrBlock = "10.0.1.0/22",
                VpcPeeringConnectionId = "pcx-0e9a7a9ecd137dc54",
            }));
        }

        return new Dictionary<string, Output<string>>
        {
        };
    }

}

Coming soon!

import pulumi
import pulumi_aws as aws

rts = aws.ec2.get_route_tables(vpc_id=var["vpc_id"],
    filters=[aws.ec2.GetRouteTablesFilterArgs(
        name="tag:kubernetes.io/kops/role",
        values=["private*"],
    )])
route = []
for range in [{"value": i} for i in range(0, len(rts.ids))]:
    route.append(aws.ec2.Route(f"route-{range['value']}",
        route_table_id=rts.ids[range["value"]],
        destination_cidr_block="10.0.1.0/22",
        vpc_peering_connection_id="pcx-0e9a7a9ecd137dc54"))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

export = async () => {
    const rts = await aws.ec2.getRouteTables({
        vpcId: _var.vpc_id,
        filters: [{
            name: "tag:kubernetes.io/kops/role",
            values: ["private*"],
        }],
    });
    const route: aws.ec2.Route[];
    for (const range = {value: 0}; range.value < rts.ids.length; range.value++) {
        route.push(new aws.ec2.Route(`route-${range.value}`, {
            routeTableId: rts.ids[range.value],
            destinationCidrBlock: "10.0.1.0/22",
            vpcPeeringConnectionId: "pcx-0e9a7a9ecd137dc54",
        }));
    }
}

Using getRouteTables

function getRouteTables(args: GetRouteTablesArgs, opts?: InvokeOptions): Promise<GetRouteTablesResult>
def get_route_tables(filters: Optional[Sequence[GetRouteTablesFilter]] = None,
                     tags: Optional[Mapping[str, str]] = None,
                     vpc_id: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetRouteTablesResult
func GetRouteTables(ctx *Context, args *GetRouteTablesArgs, opts ...InvokeOption) (*GetRouteTablesResult, error)

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

public static class GetRouteTables {
    public static Task<GetRouteTablesResult> InvokeAsync(GetRouteTablesArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<GetRouteTablesFilter>
Custom filter block as described below.
Tags Dictionary<string, string>
A map of tags, each pair of which must exactly match a pair on the desired route tables.
VpcId string
The VPC ID that you want to filter from.
Filters []GetRouteTablesFilter
Custom filter block as described below.
Tags map[string]string
A map of tags, each pair of which must exactly match a pair on the desired route tables.
VpcId string
The VPC ID that you want to filter from.
filters GetRouteTablesFilter[]
Custom filter block as described below.
tags {[key: string]: string}
A map of tags, each pair of which must exactly match a pair on the desired route tables.
vpcId string
The VPC ID that you want to filter from.
filters Sequence[GetRouteTablesFilter]
Custom filter block as described below.
tags Mapping[str, str]
A map of tags, each pair of which must exactly match a pair on the desired route tables.
vpc_id str
The VPC ID that you want to filter from.

getRouteTables Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
A set of all the route table ids found. This data source will fail if none are found.
Tags Dictionary<string, string>
Filters List<GetRouteTablesFilter>
VpcId string
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
A set of all the route table ids found. This data source will fail if none are found.
Tags map[string]string
Filters []GetRouteTablesFilter
VpcId string
id string
The provider-assigned unique ID for this managed resource.
ids string[]
A set of all the route table ids found. This data source will fail if none are found.
tags {[key: string]: string}
filters GetRouteTablesFilter[]
vpcId string
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
A set of all the route table ids found. This data source will fail if none are found.
tags Mapping[str, str]
filters Sequence[GetRouteTablesFilter]
vpc_id str

Supporting Types

GetRouteTablesFilter

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 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.

Package Details

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