1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. vpc
  5. getRouteTables
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.vpc.getRouteTables

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

This data source provides a list of Route Tables owned by an Alibaba Cloud account.

NOTE: Available since v1.36.0.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "route-tables-datasource-example-name";
const fooNetwork = new alicloud.vpc.Network("foo", {
    cidrBlock: "172.16.0.0/12",
    vpcName: name,
});
const fooRouteTable = new alicloud.vpc.RouteTable("foo", {
    vpcId: fooNetwork.id,
    routeTableName: name,
    description: name,
});
const foo = alicloud.vpc.getRouteTablesOutput({
    ids: [fooRouteTable.id],
    routeTableType: "Custom",
});
export const routeTableIds = foo.apply(foo => foo.ids);
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "route-tables-datasource-example-name"
foo_network = alicloud.vpc.Network("foo",
    cidr_block="172.16.0.0/12",
    vpc_name=name)
foo_route_table = alicloud.vpc.RouteTable("foo",
    vpc_id=foo_network.id,
    route_table_name=name,
    description=name)
foo = alicloud.vpc.get_route_tables_output(ids=[foo_route_table.id],
    route_table_type="Custom")
pulumi.export("routeTableIds", foo.ids)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
	"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, "")
name := "route-tables-datasource-example-name";
if param := cfg.Get("name"); param != ""{
name = param
}
fooNetwork, err := vpc.NewNetwork(ctx, "foo", &vpc.NetworkArgs{
CidrBlock: pulumi.String("172.16.0.0/12"),
VpcName: pulumi.String(name),
})
if err != nil {
return err
}
fooRouteTable, err := vpc.NewRouteTable(ctx, "foo", &vpc.RouteTableArgs{
VpcId: fooNetwork.ID(),
RouteTableName: pulumi.String(name),
Description: pulumi.String(name),
})
if err != nil {
return err
}
foo := vpc.GetRouteTablesOutput(ctx, vpc.GetRouteTablesOutputArgs{
Ids: pulumi.StringArray{
fooRouteTable.ID(),
},
RouteTableType: pulumi.String("Custom"),
}, nil);
ctx.Export("routeTableIds", foo.ApplyT(func(foo vpc.GetRouteTablesResult) (interface{}, error) {
return foo.Ids, nil
}).(pulumi.Interface{}Output))
return nil
})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var name = config.Get("name") ?? "route-tables-datasource-example-name";
    var fooNetwork = new AliCloud.Vpc.Network("foo", new()
    {
        CidrBlock = "172.16.0.0/12",
        VpcName = name,
    });

    var fooRouteTable = new AliCloud.Vpc.RouteTable("foo", new()
    {
        VpcId = fooNetwork.Id,
        RouteTableName = name,
        Description = name,
    });

    var foo = AliCloud.Vpc.GetRouteTables.Invoke(new()
    {
        Ids = new[]
        {
            fooRouteTable.Id,
        },
        RouteTableType = "Custom",
    });

    return new Dictionary<string, object?>
    {
        ["routeTableIds"] = foo.Apply(getRouteTablesResult => getRouteTablesResult.Ids),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.RouteTable;
import com.pulumi.alicloud.vpc.RouteTableArgs;
import com.pulumi.alicloud.vpc.VpcFunctions;
import com.pulumi.alicloud.vpc.inputs.GetRouteTablesArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var config = ctx.config();
        final var name = config.get("name").orElse("route-tables-datasource-example-name");
        var fooNetwork = new Network("fooNetwork", NetworkArgs.builder()
            .cidrBlock("172.16.0.0/12")
            .vpcName(name)
            .build());

        var fooRouteTable = new RouteTable("fooRouteTable", RouteTableArgs.builder()
            .vpcId(fooNetwork.id())
            .routeTableName(name)
            .description(name)
            .build());

        final var foo = VpcFunctions.getRouteTables(GetRouteTablesArgs.builder()
            .ids(fooRouteTable.id())
            .routeTableType("Custom")
            .build());

        ctx.export("routeTableIds", foo.applyValue(getRouteTablesResult -> getRouteTablesResult).applyValue(foo -> foo.applyValue(getRouteTablesResult -> getRouteTablesResult.ids())));
    }
}
Copy
configuration:
  name:
    type: string
    default: route-tables-datasource-example-name
resources:
  fooNetwork:
    type: alicloud:vpc:Network
    name: foo
    properties:
      cidrBlock: 172.16.0.0/12
      vpcName: ${name}
  fooRouteTable:
    type: alicloud:vpc:RouteTable
    name: foo
    properties:
      vpcId: ${fooNetwork.id}
      routeTableName: ${name}
      description: ${name}
variables:
  foo:
    fn::invoke:
      function: alicloud:vpc:getRouteTables
      arguments:
        ids:
          - ${fooRouteTable.id}
        routeTableType: Custom
outputs:
  routeTableIds: ${foo.ids}
Copy

Using getRouteTables

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getRouteTables(args: GetRouteTablesArgs, opts?: InvokeOptions): Promise<GetRouteTablesResult>
function getRouteTablesOutput(args: GetRouteTablesOutputArgs, opts?: InvokeOptions): Output<GetRouteTablesResult>
Copy
def get_route_tables(ids: Optional[Sequence[str]] = None,
                     name_regex: Optional[str] = None,
                     output_file: Optional[str] = None,
                     page_number: Optional[int] = None,
                     page_size: Optional[int] = None,
                     resource_group_id: Optional[str] = None,
                     route_table_name: Optional[str] = None,
                     route_table_type: Optional[str] = None,
                     router_id: Optional[str] = None,
                     router_type: Optional[str] = None,
                     status: Optional[str] = None,
                     tags: Optional[Mapping[str, str]] = None,
                     vpc_id: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetRouteTablesResult
def get_route_tables_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                     name_regex: Optional[pulumi.Input[str]] = None,
                     output_file: Optional[pulumi.Input[str]] = None,
                     page_number: Optional[pulumi.Input[int]] = None,
                     page_size: Optional[pulumi.Input[int]] = None,
                     resource_group_id: Optional[pulumi.Input[str]] = None,
                     route_table_name: Optional[pulumi.Input[str]] = None,
                     route_table_type: Optional[pulumi.Input[str]] = None,
                     router_id: Optional[pulumi.Input[str]] = None,
                     router_type: Optional[pulumi.Input[str]] = None,
                     status: Optional[pulumi.Input[str]] = None,
                     tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                     vpc_id: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetRouteTablesResult]
Copy
func GetRouteTables(ctx *Context, args *GetRouteTablesArgs, opts ...InvokeOption) (*GetRouteTablesResult, error)
func GetRouteTablesOutput(ctx *Context, args *GetRouteTablesOutputArgs, opts ...InvokeOption) GetRouteTablesResultOutput
Copy

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

public static class GetRouteTables 
{
    public static Task<GetRouteTablesResult> InvokeAsync(GetRouteTablesArgs args, InvokeOptions? opts = null)
    public static Output<GetRouteTablesResult> Invoke(GetRouteTablesInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetRouteTablesResult> getRouteTables(GetRouteTablesArgs args, InvokeOptions options)
public static Output<GetRouteTablesResult> getRouteTables(GetRouteTablesArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:vpc/getRouteTables:getRouteTables
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Ids Changes to this property will trigger replacement. List<string>
A list of Route Tables IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter route tables by name.
OutputFile string
File name where to save data source results (after running pulumi preview).
PageNumber int
PageSize int
ResourceGroupId Changes to this property will trigger replacement. string
The Id of resource group which route tables belongs.
RouteTableName Changes to this property will trigger replacement. string
The route table name.
RouteTableType Changes to this property will trigger replacement. string
The route table type.
RouterId Changes to this property will trigger replacement. string
The router ID.
RouterType Changes to this property will trigger replacement. string
The route type of route table. Valid values: VRouter and VBR.
Status Changes to this property will trigger replacement. string
The status of resource. Valid values: Available and Pending.
Tags Dictionary<string, string>
A mapping of tags to assign to the resource.
VpcId Changes to this property will trigger replacement. string
Vpc id of the route table.
Ids Changes to this property will trigger replacement. []string
A list of Route Tables IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter route tables by name.
OutputFile string
File name where to save data source results (after running pulumi preview).
PageNumber int
PageSize int
ResourceGroupId Changes to this property will trigger replacement. string
The Id of resource group which route tables belongs.
RouteTableName Changes to this property will trigger replacement. string
The route table name.
RouteTableType Changes to this property will trigger replacement. string
The route table type.
RouterId Changes to this property will trigger replacement. string
The router ID.
RouterType Changes to this property will trigger replacement. string
The route type of route table. Valid values: VRouter and VBR.
Status Changes to this property will trigger replacement. string
The status of resource. Valid values: Available and Pending.
Tags map[string]string
A mapping of tags to assign to the resource.
VpcId Changes to this property will trigger replacement. string
Vpc id of the route table.
ids Changes to this property will trigger replacement. List<String>
A list of Route Tables IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter route tables by name.
outputFile String
File name where to save data source results (after running pulumi preview).
pageNumber Integer
pageSize Integer
resourceGroupId Changes to this property will trigger replacement. String
The Id of resource group which route tables belongs.
routeTableName Changes to this property will trigger replacement. String
The route table name.
routeTableType Changes to this property will trigger replacement. String
The route table type.
routerId Changes to this property will trigger replacement. String
The router ID.
routerType Changes to this property will trigger replacement. String
The route type of route table. Valid values: VRouter and VBR.
status Changes to this property will trigger replacement. String
The status of resource. Valid values: Available and Pending.
tags Map<String,String>
A mapping of tags to assign to the resource.
vpcId Changes to this property will trigger replacement. String
Vpc id of the route table.
ids Changes to this property will trigger replacement. string[]
A list of Route Tables IDs.
nameRegex Changes to this property will trigger replacement. string
A regex string to filter route tables by name.
outputFile string
File name where to save data source results (after running pulumi preview).
pageNumber number
pageSize number
resourceGroupId Changes to this property will trigger replacement. string
The Id of resource group which route tables belongs.
routeTableName Changes to this property will trigger replacement. string
The route table name.
routeTableType Changes to this property will trigger replacement. string
The route table type.
routerId Changes to this property will trigger replacement. string
The router ID.
routerType Changes to this property will trigger replacement. string
The route type of route table. Valid values: VRouter and VBR.
status Changes to this property will trigger replacement. string
The status of resource. Valid values: Available and Pending.
tags {[key: string]: string}
A mapping of tags to assign to the resource.
vpcId Changes to this property will trigger replacement. string
Vpc id of the route table.
ids Changes to this property will trigger replacement. Sequence[str]
A list of Route Tables IDs.
name_regex Changes to this property will trigger replacement. str
A regex string to filter route tables by name.
output_file str
File name where to save data source results (after running pulumi preview).
page_number int
page_size int
resource_group_id Changes to this property will trigger replacement. str
The Id of resource group which route tables belongs.
route_table_name Changes to this property will trigger replacement. str
The route table name.
route_table_type Changes to this property will trigger replacement. str
The route table type.
router_id Changes to this property will trigger replacement. str
The router ID.
router_type Changes to this property will trigger replacement. str
The route type of route table. Valid values: VRouter and VBR.
status Changes to this property will trigger replacement. str
The status of resource. Valid values: Available and Pending.
tags Mapping[str, str]
A mapping of tags to assign to the resource.
vpc_id Changes to this property will trigger replacement. str
Vpc id of the route table.
ids Changes to this property will trigger replacement. List<String>
A list of Route Tables IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter route tables by name.
outputFile String
File name where to save data source results (after running pulumi preview).
pageNumber Number
pageSize Number
resourceGroupId Changes to this property will trigger replacement. String
The Id of resource group which route tables belongs.
routeTableName Changes to this property will trigger replacement. String
The route table name.
routeTableType Changes to this property will trigger replacement. String
The route table type.
routerId Changes to this property will trigger replacement. String
The router ID.
routerType Changes to this property will trigger replacement. String
The route type of route table. Valid values: VRouter and VBR.
status Changes to this property will trigger replacement. String
The status of resource. Valid values: Available and Pending.
tags Map<String>
A mapping of tags to assign to the resource.
vpcId Changes to this property will trigger replacement. String
Vpc id of the route table.

getRouteTables Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
(Optional) A list of Route Tables IDs.
Names List<string>
A list of Route Tables names.
Tables List<Pulumi.AliCloud.Vpc.Outputs.GetRouteTablesTable>
A list of Route Tables. Each element contains the following attributes:
TotalCount int
NameRegex string
OutputFile string
PageNumber int
PageSize int
ResourceGroupId string
The Id of resource group which route tables belongs.
RouteTableName string
The route table name.
RouteTableType string
The type of route table.
RouterId string
Router Id of the route table.
RouterType string
The route type.
Status string
The status of route table.
Tags Dictionary<string, string>
A mapping of tags to assign to the resource.
VpcId string
The VPC ID.
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
(Optional) A list of Route Tables IDs.
Names []string
A list of Route Tables names.
Tables []GetRouteTablesTable
A list of Route Tables. Each element contains the following attributes:
TotalCount int
NameRegex string
OutputFile string
PageNumber int
PageSize int
ResourceGroupId string
The Id of resource group which route tables belongs.
RouteTableName string
The route table name.
RouteTableType string
The type of route table.
RouterId string
Router Id of the route table.
RouterType string
The route type.
Status string
The status of route table.
Tags map[string]string
A mapping of tags to assign to the resource.
VpcId string
The VPC ID.
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
(Optional) A list of Route Tables IDs.
names List<String>
A list of Route Tables names.
tables List<GetRouteTablesTable>
A list of Route Tables. Each element contains the following attributes:
totalCount Integer
nameRegex String
outputFile String
pageNumber Integer
pageSize Integer
resourceGroupId String
The Id of resource group which route tables belongs.
routeTableName String
The route table name.
routeTableType String
The type of route table.
routerId String
Router Id of the route table.
routerType String
The route type.
status String
The status of route table.
tags Map<String,String>
A mapping of tags to assign to the resource.
vpcId String
The VPC ID.
id string
The provider-assigned unique ID for this managed resource.
ids string[]
(Optional) A list of Route Tables IDs.
names string[]
A list of Route Tables names.
tables GetRouteTablesTable[]
A list of Route Tables. Each element contains the following attributes:
totalCount number
nameRegex string
outputFile string
pageNumber number
pageSize number
resourceGroupId string
The Id of resource group which route tables belongs.
routeTableName string
The route table name.
routeTableType string
The type of route table.
routerId string
Router Id of the route table.
routerType string
The route type.
status string
The status of route table.
tags {[key: string]: string}
A mapping of tags to assign to the resource.
vpcId string
The VPC ID.
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
(Optional) A list of Route Tables IDs.
names Sequence[str]
A list of Route Tables names.
tables Sequence[GetRouteTablesTable]
A list of Route Tables. Each element contains the following attributes:
total_count int
name_regex str
output_file str
page_number int
page_size int
resource_group_id str
The Id of resource group which route tables belongs.
route_table_name str
The route table name.
route_table_type str
The type of route table.
router_id str
Router Id of the route table.
router_type str
The route type.
status str
The status of route table.
tags Mapping[str, str]
A mapping of tags to assign to the resource.
vpc_id str
The VPC ID.
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
(Optional) A list of Route Tables IDs.
names List<String>
A list of Route Tables names.
tables List<Property Map>
A list of Route Tables. Each element contains the following attributes:
totalCount Number
nameRegex String
outputFile String
pageNumber Number
pageSize Number
resourceGroupId String
The Id of resource group which route tables belongs.
routeTableName String
The route table name.
routeTableType String
The type of route table.
routerId String
Router Id of the route table.
routerType String
The route type.
status String
The status of route table.
tags Map<String>
A mapping of tags to assign to the resource.
vpcId String
The VPC ID.

Supporting Types

GetRouteTablesTable

Description This property is required. string
The description of the route table instance.
Id This property is required. string
ID of the Route Table.
Name This property is required. string
Name of the route table.
ResourceGroupId This property is required. string
The Id of resource group which route tables belongs.
RouteTableId This property is required. string
The route table id.
RouteTableName This property is required. string
The route table name.
RouteTableType This property is required. string
The route table type.
RouterId This property is required. string
The router ID.
RouterType This property is required. string
The route type of route table. Valid values: VRouter and VBR.
Status This property is required. string
The status of resource. Valid values: Available and Pending.
Tags This property is required. Dictionary<string, string>
A mapping of tags to assign to the resource.
VpcId This property is required. string
Vpc id of the route table.
VswitchIds This property is required. List<string>
A list of vswitch id.
Description This property is required. string
The description of the route table instance.
Id This property is required. string
ID of the Route Table.
Name This property is required. string
Name of the route table.
ResourceGroupId This property is required. string
The Id of resource group which route tables belongs.
RouteTableId This property is required. string
The route table id.
RouteTableName This property is required. string
The route table name.
RouteTableType This property is required. string
The route table type.
RouterId This property is required. string
The router ID.
RouterType This property is required. string
The route type of route table. Valid values: VRouter and VBR.
Status This property is required. string
The status of resource. Valid values: Available and Pending.
Tags This property is required. map[string]string
A mapping of tags to assign to the resource.
VpcId This property is required. string
Vpc id of the route table.
VswitchIds This property is required. []string
A list of vswitch id.
description This property is required. String
The description of the route table instance.
id This property is required. String
ID of the Route Table.
name This property is required. String
Name of the route table.
resourceGroupId This property is required. String
The Id of resource group which route tables belongs.
routeTableId This property is required. String
The route table id.
routeTableName This property is required. String
The route table name.
routeTableType This property is required. String
The route table type.
routerId This property is required. String
The router ID.
routerType This property is required. String
The route type of route table. Valid values: VRouter and VBR.
status This property is required. String
The status of resource. Valid values: Available and Pending.
tags This property is required. Map<String,String>
A mapping of tags to assign to the resource.
vpcId This property is required. String
Vpc id of the route table.
vswitchIds This property is required. List<String>
A list of vswitch id.
description This property is required. string
The description of the route table instance.
id This property is required. string
ID of the Route Table.
name This property is required. string
Name of the route table.
resourceGroupId This property is required. string
The Id of resource group which route tables belongs.
routeTableId This property is required. string
The route table id.
routeTableName This property is required. string
The route table name.
routeTableType This property is required. string
The route table type.
routerId This property is required. string
The router ID.
routerType This property is required. string
The route type of route table. Valid values: VRouter and VBR.
status This property is required. string
The status of resource. Valid values: Available and Pending.
tags This property is required. {[key: string]: string}
A mapping of tags to assign to the resource.
vpcId This property is required. string
Vpc id of the route table.
vswitchIds This property is required. string[]
A list of vswitch id.
description This property is required. str
The description of the route table instance.
id This property is required. str
ID of the Route Table.
name This property is required. str
Name of the route table.
resource_group_id This property is required. str
The Id of resource group which route tables belongs.
route_table_id This property is required. str
The route table id.
route_table_name This property is required. str
The route table name.
route_table_type This property is required. str
The route table type.
router_id This property is required. str
The router ID.
router_type This property is required. str
The route type of route table. Valid values: VRouter and VBR.
status This property is required. str
The status of resource. Valid values: Available and Pending.
tags This property is required. Mapping[str, str]
A mapping of tags to assign to the resource.
vpc_id This property is required. str
Vpc id of the route table.
vswitch_ids This property is required. Sequence[str]
A list of vswitch id.
description This property is required. String
The description of the route table instance.
id This property is required. String
ID of the Route Table.
name This property is required. String
Name of the route table.
resourceGroupId This property is required. String
The Id of resource group which route tables belongs.
routeTableId This property is required. String
The route table id.
routeTableName This property is required. String
The route table name.
routeTableType This property is required. String
The route table type.
routerId This property is required. String
The router ID.
routerType This property is required. String
The route type of route table. Valid values: VRouter and VBR.
status This property is required. String
The status of resource. Valid values: Available and Pending.
tags This property is required. Map<String>
A mapping of tags to assign to the resource.
vpcId This property is required. String
Vpc id of the route table.
vswitchIds This property is required. List<String>
A list of vswitch id.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi