published on Thursday, Sep 24, 2026 by ucloud
published on Thursday, Sep 24, 2026 by ucloud
Provides a Route Table Rule resource under a VPC route table. A route table rule describes how traffic destined for a specific destination network segment is forwarded to a next hop (an instance or a private VIP).
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as ucloud from "@pulumi/ucloud";
const foo = new ucloud.Vpc("foo", {
name: "tf-example-vpc",
tag: "tf-example",
cidrBlocks: ["192.168.0.0/16"],
});
const fooSubnet = new ucloud.Subnet("foo", {
name: "tf-example-subnet",
tag: "tf-example",
cidrBlock: "192.168.1.0/24",
vpcId: foo.vpcId,
});
const fooVip = new ucloud.Vip("foo", {
vpcId: foo.vpcId,
subnetId: fooSubnet.subnetId,
name: "tf-example-vip",
tag: "tf-example",
});
const fooRouteTable = new ucloud.RouteTable("foo", {
name: "tf-example-route-table",
tag: "tf-example",
vpcId: foo.vpcId,
});
const fooRouteTableRule = new ucloud.RouteTableRule("foo", {
routeTableId: fooRouteTable.routeTableId,
dstAddr: "10.8.0.0/16",
nexthopType: "vip",
nexthopId: fooVip.vipId,
remark: "tf-example-route-table-rule",
});
import pulumi
import pulumi_ucloud as ucloud
foo = ucloud.Vpc("foo",
name="tf-example-vpc",
tag="tf-example",
cidr_blocks=["192.168.0.0/16"])
foo_subnet = ucloud.Subnet("foo",
name="tf-example-subnet",
tag="tf-example",
cidr_block="192.168.1.0/24",
vpc_id=foo.vpc_id)
foo_vip = ucloud.Vip("foo",
vpc_id=foo.vpc_id,
subnet_id=foo_subnet.subnet_id,
name="tf-example-vip",
tag="tf-example")
foo_route_table = ucloud.RouteTable("foo",
name="tf-example-route-table",
tag="tf-example",
vpc_id=foo.vpc_id)
foo_route_table_rule = ucloud.RouteTableRule("foo",
route_table_id=foo_route_table.route_table_id,
dst_addr="10.8.0.0/16",
nexthop_type="vip",
nexthop_id=foo_vip.vip_id,
remark="tf-example-route-table-rule")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
foo, err := ucloud.NewVpc(ctx, "foo", &ucloud.VpcArgs{
Name: pulumi.String("tf-example-vpc"),
Tag: pulumi.String("tf-example"),
CidrBlocks: pulumi.StringArray{
pulumi.String("192.168.0.0/16"),
},
})
if err != nil {
return err
}
fooSubnet, err := ucloud.NewSubnet(ctx, "foo", &ucloud.SubnetArgs{
Name: pulumi.String("tf-example-subnet"),
Tag: pulumi.String("tf-example"),
CidrBlock: pulumi.String("192.168.1.0/24"),
VpcId: foo.VpcId,
})
if err != nil {
return err
}
fooVip, err := ucloud.NewVip(ctx, "foo", &ucloud.VipArgs{
VpcId: foo.VpcId,
SubnetId: fooSubnet.SubnetId,
Name: pulumi.String("tf-example-vip"),
Tag: pulumi.String("tf-example"),
})
if err != nil {
return err
}
fooRouteTable, err := ucloud.NewRouteTable(ctx, "foo", &ucloud.RouteTableArgs{
Name: pulumi.String("tf-example-route-table"),
Tag: pulumi.String("tf-example"),
VpcId: foo.VpcId,
})
if err != nil {
return err
}
_, err = ucloud.NewRouteTableRule(ctx, "foo", &ucloud.RouteTableRuleArgs{
RouteTableId: fooRouteTable.RouteTableId,
DstAddr: pulumi.String("10.8.0.0/16"),
NexthopType: pulumi.String("vip"),
NexthopId: fooVip.VipId,
Remark: pulumi.String("tf-example-route-table-rule"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ucloud = Pulumi.Ucloud;
return await Deployment.RunAsync(() =>
{
var foo = new Ucloud.Vpc("foo", new()
{
Name = "tf-example-vpc",
Tag = "tf-example",
CidrBlocks = new[]
{
"192.168.0.0/16",
},
});
var fooSubnet = new Ucloud.Subnet("foo", new()
{
Name = "tf-example-subnet",
Tag = "tf-example",
CidrBlock = "192.168.1.0/24",
VpcId = foo.VpcId,
});
var fooVip = new Ucloud.Vip("foo", new()
{
VpcId = foo.VpcId,
SubnetId = fooSubnet.SubnetId,
Name = "tf-example-vip",
Tag = "tf-example",
});
var fooRouteTable = new Ucloud.RouteTable("foo", new()
{
Name = "tf-example-route-table",
Tag = "tf-example",
VpcId = foo.VpcId,
});
var fooRouteTableRule = new Ucloud.RouteTableRule("foo", new()
{
RouteTableId = fooRouteTable.RouteTableId,
DstAddr = "10.8.0.0/16",
NexthopType = "vip",
NexthopId = fooVip.VipId,
Remark = "tf-example-route-table-rule",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ucloud.Vpc;
import com.pulumi.ucloud.VpcArgs;
import com.pulumi.ucloud.Subnet;
import com.pulumi.ucloud.SubnetArgs;
import com.pulumi.ucloud.Vip;
import com.pulumi.ucloud.VipArgs;
import com.pulumi.ucloud.RouteTable;
import com.pulumi.ucloud.RouteTableArgs;
import com.pulumi.ucloud.RouteTableRule;
import com.pulumi.ucloud.RouteTableRuleArgs;
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) {
var foo = new Vpc("foo", VpcArgs.builder()
.name("tf-example-vpc")
.tag("tf-example")
.cidrBlocks("192.168.0.0/16")
.build());
var fooSubnet = new Subnet("fooSubnet", SubnetArgs.builder()
.name("tf-example-subnet")
.tag("tf-example")
.cidrBlock("192.168.1.0/24")
.vpcId(foo.vpcId())
.build());
var fooVip = new Vip("fooVip", VipArgs.builder()
.vpcId(foo.vpcId())
.subnetId(fooSubnet.subnetId())
.name("tf-example-vip")
.tag("tf-example")
.build());
var fooRouteTable = new RouteTable("fooRouteTable", RouteTableArgs.builder()
.name("tf-example-route-table")
.tag("tf-example")
.vpcId(foo.vpcId())
.build());
var fooRouteTableRule = new RouteTableRule("fooRouteTableRule", RouteTableRuleArgs.builder()
.routeTableId(fooRouteTable.routeTableId())
.dstAddr("10.8.0.0/16")
.nexthopType("vip")
.nexthopId(fooVip.vipId())
.remark("tf-example-route-table-rule")
.build());
}
}
resources:
foo:
type: ucloud:Vpc
properties:
name: tf-example-vpc
tag: tf-example
cidrBlocks:
- 192.168.0.0/16
fooSubnet:
type: ucloud:Subnet
name: foo
properties:
name: tf-example-subnet
tag: tf-example
cidrBlock: 192.168.1.0/24
vpcId: ${foo.vpcId}
fooVip:
type: ucloud:Vip
name: foo
properties:
vpcId: ${foo.vpcId}
subnetId: ${fooSubnet.subnetId}
name: tf-example-vip
tag: tf-example
fooRouteTable:
type: ucloud:RouteTable
name: foo
properties:
name: tf-example-route-table
tag: tf-example
vpcId: ${foo.vpcId}
fooRouteTableRule:
type: ucloud:RouteTableRule
name: foo
properties:
routeTableId: ${fooRouteTable.routeTableId}
dstAddr: 10.8.0.0/16
nexthopType: vip
nexthopId: ${fooVip.vipId}
remark: tf-example-route-table-rule
Example coming soon!
Create RouteTableRule Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RouteTableRule(name: string, args: RouteTableRuleArgs, opts?: CustomResourceOptions);@overload
def RouteTableRule(resource_name: str,
args: RouteTableRuleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def RouteTableRule(resource_name: str,
opts: Optional[ResourceOptions] = None,
dst_addr: Optional[str] = None,
nexthop_id: Optional[str] = None,
nexthop_type: Optional[str] = None,
route_table_id: Optional[str] = None,
remark: Optional[str] = None,
route_table_rule_id: Optional[str] = None)func NewRouteTableRule(ctx *Context, name string, args RouteTableRuleArgs, opts ...ResourceOption) (*RouteTableRule, error)public RouteTableRule(string name, RouteTableRuleArgs args, CustomResourceOptions? opts = null)
public RouteTableRule(String name, RouteTableRuleArgs args)
public RouteTableRule(String name, RouteTableRuleArgs args, CustomResourceOptions options)
type: ucloud:RouteTableRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "ucloud_route_table_rule" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args RouteTableRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args RouteTableRuleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args RouteTableRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RouteTableRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RouteTableRuleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var routeTableRuleResource = new Ucloud.RouteTableRule("routeTableRuleResource", new()
{
DstAddr = "string",
NexthopId = "string",
NexthopType = "string",
RouteTableId = "string",
Remark = "string",
RouteTableRuleId = "string",
});
example, err := ucloud.NewRouteTableRule(ctx, "routeTableRuleResource", &ucloud.RouteTableRuleArgs{
DstAddr: pulumi.String("string"),
NexthopId: pulumi.String("string"),
NexthopType: pulumi.String("string"),
RouteTableId: pulumi.String("string"),
Remark: pulumi.String("string"),
RouteTableRuleId: pulumi.String("string"),
})
resource "ucloud_route_table_rule" "routeTableRuleResource" {
lifecycle {
create_before_destroy = true
}
dst_addr = "string"
nexthop_id = "string"
nexthop_type = "string"
route_table_id = "string"
remark = "string"
route_table_rule_id = "string"
}
var routeTableRuleResource = new RouteTableRule("routeTableRuleResource", RouteTableRuleArgs.builder()
.dstAddr("string")
.nexthopId("string")
.nexthopType("string")
.routeTableId("string")
.remark("string")
.routeTableRuleId("string")
.build());
route_table_rule_resource = ucloud.RouteTableRule("routeTableRuleResource",
dst_addr="string",
nexthop_id="string",
nexthop_type="string",
route_table_id="string",
remark="string",
route_table_rule_id="string")
const routeTableRuleResource = new ucloud.RouteTableRule("routeTableRuleResource", {
dstAddr: "string",
nexthopId: "string",
nexthopType: "string",
routeTableId: "string",
remark: "string",
routeTableRuleId: "string",
});
type: ucloud:RouteTableRule
properties:
dstAddr: string
nexthopId: string
nexthopType: string
remark: string
routeTableId: string
routeTableRuleId: string
RouteTableRule Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The RouteTableRule resource accepts the following input properties:
- Dst
Addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - Nexthop
Id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - Nexthop
Type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - Route
Table stringId - The ID of the route table that the rule belongs to.
- Remark string
- The remarks of the route rule. (Default:
""). - Route
Table stringRule Id - The ID of the route table rule.
- Dst
Addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - Nexthop
Id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - Nexthop
Type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - Route
Table stringId - The ID of the route table that the rule belongs to.
- Remark string
- The remarks of the route rule. (Default:
""). - Route
Table stringRule Id - The ID of the route table rule.
- dst_
addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop_
id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop_
type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - route_
table_ stringid - The ID of the route table that the rule belongs to.
- remark string
- The remarks of the route rule. (Default:
""). - route_
table_ stringrule_ id - The ID of the route table rule.
- dst
Addr String - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop
Id String - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop
Type String - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - route
Table StringId - The ID of the route table that the rule belongs to.
- remark String
- The remarks of the route rule. (Default:
""). - route
Table StringRule Id - The ID of the route table rule.
- dst
Addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop
Id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop
Type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - route
Table stringId - The ID of the route table that the rule belongs to.
- remark string
- The remarks of the route rule. (Default:
""). - route
Table stringRule Id - The ID of the route table rule.
- dst_
addr str - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop_
id str - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop_
type str - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - route_
table_ strid - The ID of the route table that the rule belongs to.
- remark str
- The remarks of the route rule. (Default:
""). - route_
table_ strrule_ id - The ID of the route table rule.
- dst
Addr String - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop
Id String - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop
Type String - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - route
Table StringId - The ID of the route table that the rule belongs to.
- remark String
- The remarks of the route rule. (Default:
""). - route
Table StringRule Id - The ID of the route table rule.
Outputs
All input properties are implicitly available as output properties. Additionally, the RouteTableRule resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing RouteTableRule Resource
Get an existing RouteTableRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: RouteTableRuleState, opts?: CustomResourceOptions): RouteTableRule@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
dst_addr: Optional[str] = None,
nexthop_id: Optional[str] = None,
nexthop_type: Optional[str] = None,
remark: Optional[str] = None,
route_table_id: Optional[str] = None,
route_table_rule_id: Optional[str] = None) -> RouteTableRulefunc GetRouteTableRule(ctx *Context, name string, id IDInput, state *RouteTableRuleState, opts ...ResourceOption) (*RouteTableRule, error)public static RouteTableRule Get(string name, Input<string> id, RouteTableRuleState? state, CustomResourceOptions? opts = null)public static RouteTableRule get(String name, Output<String> id, RouteTableRuleState state, CustomResourceOptions options)resources: _: type: ucloud:RouteTableRule get: id: ${id}import {
to = ucloud_route_table_rule.example
id = "${id}"
}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Dst
Addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - Nexthop
Id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - Nexthop
Type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - Remark string
- The remarks of the route rule. (Default:
""). - Route
Table stringId - The ID of the route table that the rule belongs to.
- Route
Table stringRule Id - The ID of the route table rule.
- Dst
Addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - Nexthop
Id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - Nexthop
Type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - Remark string
- The remarks of the route rule. (Default:
""). - Route
Table stringId - The ID of the route table that the rule belongs to.
- Route
Table stringRule Id - The ID of the route table rule.
- dst_
addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop_
id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop_
type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - remark string
- The remarks of the route rule. (Default:
""). - route_
table_ stringid - The ID of the route table that the rule belongs to.
- route_
table_ stringrule_ id - The ID of the route table rule.
- dst
Addr String - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop
Id String - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop
Type String - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - remark String
- The remarks of the route rule. (Default:
""). - route
Table StringId - The ID of the route table that the rule belongs to.
- route
Table StringRule Id - The ID of the route table rule.
- dst
Addr string - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop
Id string - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop
Type string - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - remark string
- The remarks of the route rule. (Default:
""). - route
Table stringId - The ID of the route table that the rule belongs to.
- route
Table stringRule Id - The ID of the route table rule.
- dst_
addr str - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop_
id str - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop_
type str - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - remark str
- The remarks of the route rule. (Default:
""). - route_
table_ strid - The ID of the route table that the rule belongs to.
- route_
table_ strrule_ id - The ID of the route table rule.
- dst
Addr String - The destination network segment of the route rule, an IPv4 address or CIDR network, e.g.
10.8.0.0/16or0.0.0.0/0. - nexthop
Id String - The ID of the next hop resource. For
instanceit is a UHost instance ID, forvipit is a private VIP ID. - nexthop
Type String - The type of the next hop,
instancefor a cloud host instance,vipfor a private VIP. - remark String
- The remarks of the route rule. (Default:
""). - route
Table StringId - The ID of the route table that the rule belongs to.
- route
Table StringRule Id - The ID of the route table rule.
Import
Route Table Rule is not importable because its identity also depends on the parent route table ID.
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- ucloud ucloud/terraform-provider-ucloud
- License
- Notes
- This Pulumi package is based on the
ucloudTerraform Provider.
published on Thursday, Sep 24, 2026 by ucloud