Try AWS Native preview for resources not in the classic version.
aws.ec2.getRouteTable
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
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.
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",
});
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")
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/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")
selected, err := ec2.LookupRouteTable(ctx, &ec2.LookupRouteTableArgs{
SubnetId: pulumi.StringRef(subnetId),
}, 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
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var subnetId = config.RequireObject<dynamic>("subnetId");
var selected = Aws.Ec2.GetRouteTable.Invoke(new()
{
SubnetId = subnetId,
});
var route = new Aws.Ec2.Route("route", new()
{
RouteTableId = selected.Apply(getRouteTableResult => getRouteTableResult.Id),
DestinationCidrBlock = "10.0.1.0/22",
VpcPeeringConnectionId = "pcx-45ff3dc1",
});
});
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());
}
}
configuration:
subnetId:
type: dynamic
resources:
route:
type: aws:ec2:Route
properties:
routeTableId: ${selected.id}
destinationCidrBlock: 10.0.1.0/22
vpcPeeringConnectionId: pcx-45ff3dc1
variables:
selected:
fn::invoke:
Function: aws:ec2:getRouteTable
Arguments:
subnetId: ${subnetId}
Using getRouteTable
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 getRouteTable(args: GetRouteTableArgs, opts?: InvokeOptions): Promise<GetRouteTableResult>
function getRouteTableOutput(args: GetRouteTableOutputArgs, opts?: InvokeOptions): Output<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
def get_route_table_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetRouteTableFilterArgs]]]] = None,
gateway_id: Optional[pulumi.Input[str]] = None,
route_table_id: Optional[pulumi.Input[str]] = None,
subnet_id: 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[GetRouteTableResult]
func LookupRouteTable(ctx *Context, args *LookupRouteTableArgs, opts ...InvokeOption) (*LookupRouteTableResult, error)
func LookupRouteTableOutput(ctx *Context, args *LookupRouteTableOutputArgs, opts ...InvokeOption) LookupRouteTableResultOutput
> Note: This function is named LookupRouteTable
in the Go SDK.
public static class GetRouteTable
{
public static Task<GetRouteTableResult> InvokeAsync(GetRouteTableArgs args, InvokeOptions? opts = null)
public static Output<GetRouteTableResult> Invoke(GetRouteTableInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetRouteTableResult> getRouteTable(GetRouteTableArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:ec2/getRouteTable:getRouteTable
arguments:
# arguments dictionary
The following arguments are supported:
- Filters
List<Get
Route Table Filter> - Configuration block. Detailed below.
- Gateway
Id 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).
- Route
Table stringId - ID of the specific Route Table to retrieve.
- Subnet
Id string - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- Dictionary<string, string>
- Map of tags, each pair of which must exactly match a pair on the desired Route Table.
- Vpc
Id string - ID of the VPC that the desired Route Table belongs to.
- Filters
[]Get
Route Table Filter - Configuration block. Detailed below.
- Gateway
Id 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).
- Route
Table stringId - ID of the specific Route Table to retrieve.
- Subnet
Id string - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- map[string]string
- Map of tags, each pair of which must exactly match a pair on the desired Route Table.
- Vpc
Id string - ID of the VPC that the desired Route Table belongs to.
- filters
List<Get
Route Table Filter> - Configuration block. Detailed below.
- gateway
Id 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).
- route
Table StringId - ID of the specific Route Table to retrieve.
- subnet
Id String - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- Map<String,String>
- Map of tags, each pair of which must exactly match a pair on the desired Route Table.
- vpc
Id String - ID of the VPC that the desired Route Table belongs to.
- filters
Get
Route Table Filter[] - Configuration block. Detailed below.
- gateway
Id 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).
- route
Table stringId - ID of the specific Route Table to retrieve.
- subnet
Id string - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- {[key: string]: string}
- Map of tags, each pair of which must exactly match a pair on the desired Route Table.
- vpc
Id string - ID of the VPC that the desired Route Table belongs to.
- filters
Sequence[Get
Route Table Filter] - 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_ strid - 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).
- 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.
- filters List<Property Map>
- Configuration block. Detailed below.
- gateway
Id 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).
- route
Table StringId - ID of the specific Route Table to retrieve.
- subnet
Id String - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- Map<String>
- Map of tags, each pair of which must exactly match a pair on the desired Route Table.
- vpc
Id String - 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<Get
Route Table Association> - List of associations with attributes detailed below.
- Gateway
Id 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.
- Owner
Id string - ID of the AWS account that owns the route table.
- Route
Table stringId - Route Table ID.
- Routes
List<Get
Route Table Route> - List of routes with attributes detailed below.
- Subnet
Id string - Subnet ID. Only set when associated with a subnet.
- Dictionary<string, string>
- Vpc
Id string - Filters
List<Get
Route Table Filter>
- Arn string
- ARN of the route table.
- Associations
[]Get
Route Table Association Type - List of associations with attributes detailed below.
- Gateway
Id 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.
- Owner
Id string - ID of the AWS account that owns the route table.
- Route
Table stringId - Route Table ID.
- Routes
[]Get
Route Table Route - List of routes with attributes detailed below.
- Subnet
Id string - Subnet ID. Only set when associated with a subnet.
- map[string]string
- Vpc
Id string - Filters
[]Get
Route Table Filter
- arn String
- ARN of the route table.
- associations
List<Get
Route Table Association> - List of associations with attributes detailed below.
- gateway
Id 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.
- owner
Id String - ID of the AWS account that owns the route table.
- route
Table StringId - Route Table ID.
- routes
List<Get
Route Table Route> - List of routes with attributes detailed below.
- subnet
Id String - Subnet ID. Only set when associated with a subnet.
- Map<String,String>
- vpc
Id String - filters
List<Get
Route Table Filter>
- arn string
- ARN of the route table.
- associations
Get
Route Table Association[] - List of associations with attributes detailed below.
- gateway
Id 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.
- owner
Id string - ID of the AWS account that owns the route table.
- route
Table stringId - Route Table ID.
- routes
Get
Route Table Route[] - List of routes with attributes detailed below.
- subnet
Id string - Subnet ID. Only set when associated with a subnet.
- {[key: string]: string}
- vpc
Id string - filters
Get
Route Table Filter[]
- arn str
- ARN of the route table.
- associations
Sequence[Get
Route Table Association] - 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_ strid - Route Table ID.
- routes
Sequence[Get
Route Table Route] - List of routes with attributes detailed below.
- subnet_
id str - Subnet ID. Only set when associated with a subnet.
- Mapping[str, str]
- vpc_
id str - filters
Sequence[Get
Route Table Filter]
- arn String
- ARN of the route table.
- associations List<Property Map>
- List of associations with attributes detailed below.
- gateway
Id 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.
- owner
Id String - ID of the AWS account that owns the route table.
- route
Table StringId - Route Table ID.
- routes List<Property Map>
- List of routes with attributes detailed below.
- subnet
Id String - Subnet ID. Only set when associated with a subnet.
- Map<String>
- vpc
Id String - filters List<Property Map>
Supporting Types
GetRouteTableAssociation
- Gateway
Id 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.
- Route
Table stringAssociation Id - Association ID.
- Route
Table stringId - ID of the specific Route Table to retrieve.
- Subnet
Id string - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- Gateway
Id 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.
- Route
Table stringAssociation Id - Association ID.
- Route
Table stringId - ID of the specific Route Table to retrieve.
- Subnet
Id string - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- gateway
Id 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.
- route
Table StringAssociation Id - Association ID.
- route
Table StringId - ID of the specific Route Table to retrieve.
- subnet
Id String - ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter).
- gateway
Id 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.
- route
Table stringAssociation Id - Association ID.
- route
Table stringId - ID of the specific Route Table to retrieve.
- subnet
Id 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_ strassociation_ id - Association ID.
- route_
table_ strid - 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).
- gateway
Id 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.
- route
Table StringAssociation Id - Association ID.
- route
Table StringId - ID of the specific Route Table to retrieve.
- subnet
Id String - 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 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 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.
- 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.
GetRouteTableRoute
- Carrier
Gateway stringId - ID of the Carrier Gateway.
- Cidr
Block string - CIDR block of the route.
- Core
Network stringArn - ARN of the core network.
- Destination
Prefix stringList Id - The ID of a managed prefix list destination of the route.
- Egress
Only stringGateway Id - ID of the Egress Only Internet Gateway.
- Gateway
Id 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).
- Instance
Id string - EC2 instance ID.
- Ipv6Cidr
Block string - IPv6 CIDR block of the route.
- Local
Gateway stringId - Local Gateway ID.
- Nat
Gateway stringId - NAT Gateway ID.
- Network
Interface stringId - ID of the elastic network interface (eni) to use.
- Transit
Gateway stringId - EC2 Transit Gateway ID.
- Vpc
Endpoint stringId - VPC Endpoint ID.
- Vpc
Peering stringConnection Id - VPC Peering ID.
- Carrier
Gateway stringId - ID of the Carrier Gateway.
- Cidr
Block string - CIDR block of the route.
- Core
Network stringArn - ARN of the core network.
- Destination
Prefix stringList Id - The ID of a managed prefix list destination of the route.
- Egress
Only stringGateway Id - ID of the Egress Only Internet Gateway.
- Gateway
Id 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).
- Instance
Id string - EC2 instance ID.
- Ipv6Cidr
Block string - IPv6 CIDR block of the route.
- Local
Gateway stringId - Local Gateway ID.
- Nat
Gateway stringId - NAT Gateway ID.
- Network
Interface stringId - ID of the elastic network interface (eni) to use.
- Transit
Gateway stringId - EC2 Transit Gateway ID.
- Vpc
Endpoint stringId - VPC Endpoint ID.
- Vpc
Peering stringConnection Id - VPC Peering ID.
- carrier
Gateway StringId - ID of the Carrier Gateway.
- cidr
Block String - CIDR block of the route.
- core
Network StringArn - ARN of the core network.
- destination
Prefix StringList Id - The ID of a managed prefix list destination of the route.
- egress
Only StringGateway Id - ID of the Egress Only Internet Gateway.
- gateway
Id 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).
- instance
Id String - EC2 instance ID.
- ipv6Cidr
Block String - IPv6 CIDR block of the route.
- local
Gateway StringId - Local Gateway ID.
- nat
Gateway StringId - NAT Gateway ID.
- network
Interface StringId - ID of the elastic network interface (eni) to use.
- transit
Gateway StringId - EC2 Transit Gateway ID.
- vpc
Endpoint StringId - VPC Endpoint ID.
- vpc
Peering StringConnection Id - VPC Peering ID.
- carrier
Gateway stringId - ID of the Carrier Gateway.
- cidr
Block string - CIDR block of the route.
- core
Network stringArn - ARN of the core network.
- destination
Prefix stringList Id - The ID of a managed prefix list destination of the route.
- egress
Only stringGateway Id - ID of the Egress Only Internet Gateway.
- gateway
Id 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).
- instance
Id string - EC2 instance ID.
- ipv6Cidr
Block string - IPv6 CIDR block of the route.
- local
Gateway stringId - Local Gateway ID.
- nat
Gateway stringId - NAT Gateway ID.
- network
Interface stringId - ID of the elastic network interface (eni) to use.
- transit
Gateway stringId - EC2 Transit Gateway ID.
- vpc
Endpoint stringId - VPC Endpoint ID.
- vpc
Peering stringConnection Id - VPC Peering ID.
- carrier_
gateway_ strid - ID of the Carrier Gateway.
- cidr_
block str - CIDR block of the route.
- core_
network_ strarn - ARN of the core network.
- destination_
prefix_ strlist_ id - The ID of a managed prefix list destination of the route.
- egress_
only_ strgateway_ id - 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_ strblock - IPv6 CIDR block of the route.
- local_
gateway_ strid - Local Gateway ID.
- nat_
gateway_ strid - NAT Gateway ID.
- network_
interface_ strid - ID of the elastic network interface (eni) to use.
- transit_
gateway_ strid - EC2 Transit Gateway ID.
- vpc_
endpoint_ strid - VPC Endpoint ID.
- vpc_
peering_ strconnection_ id - VPC Peering ID.
- carrier
Gateway StringId - ID of the Carrier Gateway.
- cidr
Block String - CIDR block of the route.
- core
Network StringArn - ARN of the core network.
- destination
Prefix StringList Id - The ID of a managed prefix list destination of the route.
- egress
Only StringGateway Id - ID of the Egress Only Internet Gateway.
- gateway
Id 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).
- instance
Id String - EC2 instance ID.
- ipv6Cidr
Block String - IPv6 CIDR block of the route.
- local
Gateway StringId - Local Gateway ID.
- nat
Gateway StringId - NAT Gateway ID.
- network
Interface StringId - ID of the elastic network interface (eni) to use.
- transit
Gateway StringId - EC2 Transit Gateway ID.
- vpc
Endpoint StringId - VPC Endpoint ID.
- vpc
Peering StringConnection Id - VPC Peering ID.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.