alicloud.vpc.RouteTableAttachment
Explore with Pulumi AI
Provides a VPC Route Table Attachment resource. Routing table associated resource type.
For information about VPC Route Table Attachment and how to use it, see What is Route Table Attachment.
NOTE: Available since v1.194.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const foo = new alicloud.vpc.Network("foo", {
cidrBlock: "172.16.0.0/12",
vpcName: name,
});
const default = alicloud.getZones({
availableResourceCreation: "VSwitch",
});
const fooSwitch = new alicloud.vpc.Switch("foo", {
vpcId: foo.id,
cidrBlock: "172.16.0.0/21",
zoneId: _default.then(_default => _default.zones?.[0]?.id),
vswitchName: name,
});
const fooRouteTable = new alicloud.vpc.RouteTable("foo", {
vpcId: foo.id,
routeTableName: name,
description: "route_table_attachment",
});
const fooRouteTableAttachment = new alicloud.vpc.RouteTableAttachment("foo", {
vswitchId: fooSwitch.id,
routeTableId: fooRouteTable.id,
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
foo = alicloud.vpc.Network("foo",
cidr_block="172.16.0.0/12",
vpc_name=name)
default = alicloud.get_zones(available_resource_creation="VSwitch")
foo_switch = alicloud.vpc.Switch("foo",
vpc_id=foo.id,
cidr_block="172.16.0.0/21",
zone_id=default.zones[0].id,
vswitch_name=name)
foo_route_table = alicloud.vpc.RouteTable("foo",
vpc_id=foo.id,
route_table_name=name,
description="route_table_attachment")
foo_route_table_attachment = alicloud.vpc.RouteTableAttachment("foo",
vswitch_id=foo_switch.id,
route_table_id=foo_route_table.id)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
"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 := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
foo, err := vpc.NewNetwork(ctx, "foo", &vpc.NetworkArgs{
CidrBlock: pulumi.String("172.16.0.0/12"),
VpcName: pulumi.String(name),
})
if err != nil {
return err
}
_default, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
AvailableResourceCreation: pulumi.StringRef("VSwitch"),
}, nil)
if err != nil {
return err
}
fooSwitch, err := vpc.NewSwitch(ctx, "foo", &vpc.SwitchArgs{
VpcId: foo.ID(),
CidrBlock: pulumi.String("172.16.0.0/21"),
ZoneId: pulumi.String(_default.Zones[0].Id),
VswitchName: pulumi.String(name),
})
if err != nil {
return err
}
fooRouteTable, err := vpc.NewRouteTable(ctx, "foo", &vpc.RouteTableArgs{
VpcId: foo.ID(),
RouteTableName: pulumi.String(name),
Description: pulumi.String("route_table_attachment"),
})
if err != nil {
return err
}
_, err = vpc.NewRouteTableAttachment(ctx, "foo", &vpc.RouteTableAttachmentArgs{
VswitchId: fooSwitch.ID(),
RouteTableId: fooRouteTable.ID(),
})
if err != nil {
return err
}
return nil
})
}
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") ?? "terraform-example";
var foo = new AliCloud.Vpc.Network("foo", new()
{
CidrBlock = "172.16.0.0/12",
VpcName = name,
});
var @default = AliCloud.GetZones.Invoke(new()
{
AvailableResourceCreation = "VSwitch",
});
var fooSwitch = new AliCloud.Vpc.Switch("foo", new()
{
VpcId = foo.Id,
CidrBlock = "172.16.0.0/21",
ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
VswitchName = name,
});
var fooRouteTable = new AliCloud.Vpc.RouteTable("foo", new()
{
VpcId = foo.Id,
RouteTableName = name,
Description = "route_table_attachment",
});
var fooRouteTableAttachment = new AliCloud.Vpc.RouteTableAttachment("foo", new()
{
VswitchId = fooSwitch.Id,
RouteTableId = fooRouteTable.Id,
});
});
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.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.vpc.RouteTable;
import com.pulumi.alicloud.vpc.RouteTableArgs;
import com.pulumi.alicloud.vpc.RouteTableAttachment;
import com.pulumi.alicloud.vpc.RouteTableAttachmentArgs;
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("terraform-example");
var foo = new Network("foo", NetworkArgs.builder()
.cidrBlock("172.16.0.0/12")
.vpcName(name)
.build());
final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("VSwitch")
.build());
var fooSwitch = new Switch("fooSwitch", SwitchArgs.builder()
.vpcId(foo.id())
.cidrBlock("172.16.0.0/21")
.zoneId(default_.zones()[0].id())
.vswitchName(name)
.build());
var fooRouteTable = new RouteTable("fooRouteTable", RouteTableArgs.builder()
.vpcId(foo.id())
.routeTableName(name)
.description("route_table_attachment")
.build());
var fooRouteTableAttachment = new RouteTableAttachment("fooRouteTableAttachment", RouteTableAttachmentArgs.builder()
.vswitchId(fooSwitch.id())
.routeTableId(fooRouteTable.id())
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
foo:
type: alicloud:vpc:Network
properties:
cidrBlock: 172.16.0.0/12
vpcName: ${name}
fooSwitch:
type: alicloud:vpc:Switch
name: foo
properties:
vpcId: ${foo.id}
cidrBlock: 172.16.0.0/21
zoneId: ${default.zones[0].id}
vswitchName: ${name}
fooRouteTable:
type: alicloud:vpc:RouteTable
name: foo
properties:
vpcId: ${foo.id}
routeTableName: ${name}
description: route_table_attachment
fooRouteTableAttachment:
type: alicloud:vpc:RouteTableAttachment
name: foo
properties:
vswitchId: ${fooSwitch.id}
routeTableId: ${fooRouteTable.id}
variables:
default:
fn::invoke:
Function: alicloud:getZones
Arguments:
availableResourceCreation: VSwitch
Create RouteTableAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RouteTableAttachment(name: string, args: RouteTableAttachmentArgs, opts?: CustomResourceOptions);
@overload
def RouteTableAttachment(resource_name: str,
args: RouteTableAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def RouteTableAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
route_table_id: Optional[str] = None,
vswitch_id: Optional[str] = None)
func NewRouteTableAttachment(ctx *Context, name string, args RouteTableAttachmentArgs, opts ...ResourceOption) (*RouteTableAttachment, error)
public RouteTableAttachment(string name, RouteTableAttachmentArgs args, CustomResourceOptions? opts = null)
public RouteTableAttachment(String name, RouteTableAttachmentArgs args)
public RouteTableAttachment(String name, RouteTableAttachmentArgs args, CustomResourceOptions options)
type: alicloud:vpc:RouteTableAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args RouteTableAttachmentArgs
- 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 RouteTableAttachmentArgs
- 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 RouteTableAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RouteTableAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RouteTableAttachmentArgs
- 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 routeTableAttachmentResource = new AliCloud.Vpc.RouteTableAttachment("routeTableAttachmentResource", new()
{
RouteTableId = "string",
VswitchId = "string",
});
example, err := vpc.NewRouteTableAttachment(ctx, "routeTableAttachmentResource", &vpc.RouteTableAttachmentArgs{
RouteTableId: pulumi.String("string"),
VswitchId: pulumi.String("string"),
})
var routeTableAttachmentResource = new RouteTableAttachment("routeTableAttachmentResource", RouteTableAttachmentArgs.builder()
.routeTableId("string")
.vswitchId("string")
.build());
route_table_attachment_resource = alicloud.vpc.RouteTableAttachment("routeTableAttachmentResource",
route_table_id="string",
vswitch_id="string")
const routeTableAttachmentResource = new alicloud.vpc.RouteTableAttachment("routeTableAttachmentResource", {
routeTableId: "string",
vswitchId: "string",
});
type: alicloud:vpc:RouteTableAttachment
properties:
routeTableId: string
vswitchId: string
RouteTableAttachment 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 RouteTableAttachment resource accepts the following input properties:
- Route
Table stringId - The ID of the route table to be bound to the switch.
- Vswitch
Id string - The ID of the switch to bind the route table.
- Route
Table stringId - The ID of the route table to be bound to the switch.
- Vswitch
Id string - The ID of the switch to bind the route table.
- route
Table StringId - The ID of the route table to be bound to the switch.
- vswitch
Id String - The ID of the switch to bind the route table.
- route
Table stringId - The ID of the route table to be bound to the switch.
- vswitch
Id string - The ID of the switch to bind the route table.
- route_
table_ strid - The ID of the route table to be bound to the switch.
- vswitch_
id str - The ID of the switch to bind the route table.
- route
Table StringId - The ID of the route table to be bound to the switch.
- vswitch
Id String - The ID of the switch to bind the route table.
Outputs
All input properties are implicitly available as output properties. Additionally, the RouteTableAttachment resource produces the following output properties:
Look up Existing RouteTableAttachment Resource
Get an existing RouteTableAttachment 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?: RouteTableAttachmentState, opts?: CustomResourceOptions): RouteTableAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
route_table_id: Optional[str] = None,
status: Optional[str] = None,
vswitch_id: Optional[str] = None) -> RouteTableAttachment
func GetRouteTableAttachment(ctx *Context, name string, id IDInput, state *RouteTableAttachmentState, opts ...ResourceOption) (*RouteTableAttachment, error)
public static RouteTableAttachment Get(string name, Input<string> id, RouteTableAttachmentState? state, CustomResourceOptions? opts = null)
public static RouteTableAttachment get(String name, Output<String> id, RouteTableAttachmentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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 stringId - The ID of the route table to be bound to the switch.
- Status string
- The status of the resource.
- Vswitch
Id string - The ID of the switch to bind the route table.
- Route
Table stringId - The ID of the route table to be bound to the switch.
- Status string
- The status of the resource.
- Vswitch
Id string - The ID of the switch to bind the route table.
- route
Table StringId - The ID of the route table to be bound to the switch.
- status String
- The status of the resource.
- vswitch
Id String - The ID of the switch to bind the route table.
- route
Table stringId - The ID of the route table to be bound to the switch.
- status string
- The status of the resource.
- vswitch
Id string - The ID of the switch to bind the route table.
- route_
table_ strid - The ID of the route table to be bound to the switch.
- status str
- The status of the resource.
- vswitch_
id str - The ID of the switch to bind the route table.
- route
Table StringId - The ID of the route table to be bound to the switch.
- status String
- The status of the resource.
- vswitch
Id String - The ID of the switch to bind the route table.
Import
VPC Route Table Attachment can be imported using the id, e.g.
$ pulumi import alicloud:vpc/routeTableAttachment:RouteTableAttachment example <route_table_id>:<vswitch_id>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.