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
        {
            Filters = 
            {
                new Aws.Ec2.Inputs.GetRouteTablesFilterArgs
                {
                    Name = "tag:kubernetes.io/kops/role",
                    Values = 
                    {
                        "private*",
                    },
                },
            },
            VpcId = @var.Vpc_id,
        });
        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
            {
                DestinationCidrBlock = "10.0.1.0/22",
                RouteTableId = rts.Ids[range.Value],
                VpcPeeringConnectionId = "pcx-0e9a7a9ecd137dc54",
            }));
        }

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

}

Coming soon!

import pulumi
import pulumi_aws as aws

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

const rts = pulumi.output(aws.ec2.getRouteTables({
    filters: [{
        name: "tag:kubernetes.io/kops/role",
        values: ["private*"],
    }],
    vpcId: var_vpc_id,
}, { async: true }));
const route: aws.ec2.Route[] = [];
for (let i = 0; i < rts.apply(rts => rts.ids.length); i++) {
    route.push(new aws.ec2.Route(`r-${i}`, {
        destinationCidrBlock: "10.0.1.0/22",
        routeTableId: rts.apply(rts => rts.ids[i]),
        vpcPeeringConnectionId: "pcx-0e9a7a9ecd137dc54",
    }));
}

Using GetRouteTables

function getRouteTables(args: GetRouteTablesArgs, opts?: InvokeOptions): Promise<GetRouteTablesResult>
function  get_route_tables(filters=None, tags=None, vpc_id=None, opts=None)
func GetRouteTables(ctx *Context, args *GetRouteTablesArgs, opts ...InvokeOption) (*GetRouteTablesResult, error)
public static class GetRouteTables {
    public static Task<GetRouteTablesResult> InvokeAsync(GetRouteTablesArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<GetRouteTablesFilterArgs>

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 List[GetRouteTablesFilter]

Custom filter block as described below.

tags Dict[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 List[str]

A set of all the route table ids found. This data source will fail if none are found.

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

Supporting Types

GetRouteTablesFilter

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.

Package Details

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