published on Thursday, Sep 24, 2026 by ucloud
published on Thursday, Sep 24, 2026 by ucloud
Provides a resource to bind a subnet to a route table. A subnet is always bound to a route table; when it is not bound to any custom route table it stays on its VPC default route table. Deleting this resource rebinds the subnet back to the default route table.
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 fooRouteTable = new ucloud.RouteTable("foo", {
name: "tf-example-route-table",
tag: "tf-example",
vpcId: foo.vpcId,
});
const fooRouteTableAssociation = new ucloud.RouteTableAssociation("foo", {
subnetId: fooSubnet.subnetId,
routeTableId: fooRouteTable.routeTableId,
});
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_route_table = ucloud.RouteTable("foo",
name="tf-example-route-table",
tag="tf-example",
vpc_id=foo.vpc_id)
foo_route_table_association = ucloud.RouteTableAssociation("foo",
subnet_id=foo_subnet.subnet_id,
route_table_id=foo_route_table.route_table_id)
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
}
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.NewRouteTableAssociation(ctx, "foo", &ucloud.RouteTableAssociationArgs{
SubnetId: fooSubnet.SubnetId,
RouteTableId: fooRouteTable.RouteTableId,
})
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 fooRouteTable = new Ucloud.RouteTable("foo", new()
{
Name = "tf-example-route-table",
Tag = "tf-example",
VpcId = foo.VpcId,
});
var fooRouteTableAssociation = new Ucloud.RouteTableAssociation("foo", new()
{
SubnetId = fooSubnet.SubnetId,
RouteTableId = fooRouteTable.RouteTableId,
});
});
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.RouteTable;
import com.pulumi.ucloud.RouteTableArgs;
import com.pulumi.ucloud.RouteTableAssociation;
import com.pulumi.ucloud.RouteTableAssociationArgs;
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 fooRouteTable = new RouteTable("fooRouteTable", RouteTableArgs.builder()
.name("tf-example-route-table")
.tag("tf-example")
.vpcId(foo.vpcId())
.build());
var fooRouteTableAssociation = new RouteTableAssociation("fooRouteTableAssociation", RouteTableAssociationArgs.builder()
.subnetId(fooSubnet.subnetId())
.routeTableId(fooRouteTable.routeTableId())
.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}
fooRouteTable:
type: ucloud:RouteTable
name: foo
properties:
name: tf-example-route-table
tag: tf-example
vpcId: ${foo.vpcId}
fooRouteTableAssociation:
type: ucloud:RouteTableAssociation
name: foo
properties:
subnetId: ${fooSubnet.subnetId}
routeTableId: ${fooRouteTable.routeTableId}
Example coming soon!
Create RouteTableAssociation Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RouteTableAssociation(name: string, args: RouteTableAssociationArgs, opts?: CustomResourceOptions);@overload
def RouteTableAssociation(resource_name: str,
args: RouteTableAssociationArgs,
opts: Optional[ResourceOptions] = None)
@overload
def RouteTableAssociation(resource_name: str,
opts: Optional[ResourceOptions] = None,
route_table_id: Optional[str] = None,
subnet_id: Optional[str] = None,
route_table_association_id: Optional[str] = None)func NewRouteTableAssociation(ctx *Context, name string, args RouteTableAssociationArgs, opts ...ResourceOption) (*RouteTableAssociation, error)public RouteTableAssociation(string name, RouteTableAssociationArgs args, CustomResourceOptions? opts = null)
public RouteTableAssociation(String name, RouteTableAssociationArgs args)
public RouteTableAssociation(String name, RouteTableAssociationArgs args, CustomResourceOptions options)
type: ucloud:RouteTableAssociation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "ucloud_route_table_association" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args RouteTableAssociationArgs
- 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 RouteTableAssociationArgs
- 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 RouteTableAssociationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RouteTableAssociationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RouteTableAssociationArgs
- 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 routeTableAssociationResource = new Ucloud.RouteTableAssociation("routeTableAssociationResource", new()
{
RouteTableId = "string",
SubnetId = "string",
RouteTableAssociationId = "string",
});
example, err := ucloud.NewRouteTableAssociation(ctx, "routeTableAssociationResource", &ucloud.RouteTableAssociationArgs{
RouteTableId: pulumi.String("string"),
SubnetId: pulumi.String("string"),
RouteTableAssociationId: pulumi.String("string"),
})
resource "ucloud_route_table_association" "routeTableAssociationResource" {
lifecycle {
create_before_destroy = true
}
route_table_id = "string"
subnet_id = "string"
route_table_association_id = "string"
}
var routeTableAssociationResource = new RouteTableAssociation("routeTableAssociationResource", RouteTableAssociationArgs.builder()
.routeTableId("string")
.subnetId("string")
.routeTableAssociationId("string")
.build());
route_table_association_resource = ucloud.RouteTableAssociation("routeTableAssociationResource",
route_table_id="string",
subnet_id="string",
route_table_association_id="string")
const routeTableAssociationResource = new ucloud.RouteTableAssociation("routeTableAssociationResource", {
routeTableId: "string",
subnetId: "string",
routeTableAssociationId: "string",
});
type: ucloud:RouteTableAssociation
properties:
routeTableAssociationId: string
routeTableId: string
subnetId: string
RouteTableAssociation 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 RouteTableAssociation resource accepts the following input properties:
- Route
Table stringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- Subnet
Id string - The ID of the subnet to bind. It is also used as the resource ID.
- Route
Table stringAssociation Id - The ID of the subnet that is bound.
- Route
Table stringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- Subnet
Id string - The ID of the subnet to bind. It is also used as the resource ID.
- Route
Table stringAssociation Id - The ID of the subnet that is bound.
- route_
table_ stringid - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet_
id string - The ID of the subnet to bind. It is also used as the resource ID.
- route_
table_ stringassociation_ id - The ID of the subnet that is bound.
- route
Table StringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet
Id String - The ID of the subnet to bind. It is also used as the resource ID.
- route
Table StringAssociation Id - The ID of the subnet that is bound.
- route
Table stringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet
Id string - The ID of the subnet to bind. It is also used as the resource ID.
- route
Table stringAssociation Id - The ID of the subnet that is bound.
- route_
table_ strid - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet_
id str - The ID of the subnet to bind. It is also used as the resource ID.
- route_
table_ strassociation_ id - The ID of the subnet that is bound.
- route
Table StringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet
Id String - The ID of the subnet to bind. It is also used as the resource ID.
- route
Table StringAssociation Id - The ID of the subnet that is bound.
Outputs
All input properties are implicitly available as output properties. Additionally, the RouteTableAssociation 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 RouteTableAssociation Resource
Get an existing RouteTableAssociation 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?: RouteTableAssociationState, opts?: CustomResourceOptions): RouteTableAssociation@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
route_table_association_id: Optional[str] = None,
route_table_id: Optional[str] = None,
subnet_id: Optional[str] = None) -> RouteTableAssociationfunc GetRouteTableAssociation(ctx *Context, name string, id IDInput, state *RouteTableAssociationState, opts ...ResourceOption) (*RouteTableAssociation, error)public static RouteTableAssociation Get(string name, Input<string> id, RouteTableAssociationState? state, CustomResourceOptions? opts = null)public static RouteTableAssociation get(String name, Output<String> id, RouteTableAssociationState state, CustomResourceOptions options)resources: _: type: ucloud:RouteTableAssociation get: id: ${id}import {
to = ucloud_route_table_association.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.
- Route
Table stringAssociation Id - The ID of the subnet that is bound.
- Route
Table stringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- Subnet
Id string - The ID of the subnet to bind. It is also used as the resource ID.
- Route
Table stringAssociation Id - The ID of the subnet that is bound.
- Route
Table stringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- Subnet
Id string - The ID of the subnet to bind. It is also used as the resource ID.
- route_
table_ stringassociation_ id - The ID of the subnet that is bound.
- route_
table_ stringid - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet_
id string - The ID of the subnet to bind. It is also used as the resource ID.
- route
Table StringAssociation Id - The ID of the subnet that is bound.
- route
Table StringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet
Id String - The ID of the subnet to bind. It is also used as the resource ID.
- route
Table stringAssociation Id - The ID of the subnet that is bound.
- route
Table stringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet
Id string - The ID of the subnet to bind. It is also used as the resource ID.
- route_
table_ strassociation_ id - The ID of the subnet that is bound.
- route_
table_ strid - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet_
id str - The ID of the subnet to bind. It is also used as the resource ID.
- route
Table StringAssociation Id - The ID of the subnet that is bound.
- route
Table StringId - The ID of the route table to bind the subnet to. Changing this moves the subnet to the new route table.
- subnet
Id String - The ID of the subnet to bind. It is also used as the resource ID.
Import
Route Table Association can be imported using the subnet_id, e.g.
$ pulumi import ucloud:index/routeTableAssociation:RouteTableAssociation example subnet-abc123456
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