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

The following example shows how one might accept a Route Table ID as a variable and use this data source to obtain the data necessary to create a route.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetRouteTableArgs;
import com.pulumi.aws.ec2.Route;
import com.pulumi.aws.ec2.RouteArgs;
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 subnetId = config.get("subnetId");
final var selected = Ec2Functions.getRouteTable(GetRouteTableArgs.builder()
.subnetId(subnetId)
.build());
var route = new Route("route", RouteArgs.builder()
.routeTableId(selected.applyValue(getRouteTableResult -> getRouteTableResult.id()))
.destinationCidrBlock("10.0.1.0/22")
.vpcPeeringConnectionId("pcx-45ff3dc1")
.build());
}
}

Return

A collection of values returned by getRouteTable.

Parameters

argument

A collection of arguments for invoking getRouteTable.


suspend fun getRouteTable(filters: List<GetRouteTableFilter>? = null, gatewayId: String? = null, routeTableId: String? = null, subnetId: String? = null, tags: Map<String, String>? = null, vpcId: String? = null): GetRouteTableResult

Return

A collection of values returned by getRouteTable.

Parameters

filters

Configuration block. Detailed below.

gatewayId

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

ID of the specific Route Table to retrieve.

subnetId

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

tags

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

vpcId

ID of the VPC that the desired Route Table belongs to.

See also


Return

A collection of values returned by getRouteTable.

Parameters

argument

Builder for com.pulumi.aws.ec2.kotlin.inputs.GetRouteTablePlainArgs.

See also