alicloud logo
Alibaba Cloud v3.34.0, Mar 17 23

alicloud.vpc.RouteTableAttachment

Import

The route table attachment can be imported using the id, e.g.

 $ pulumi import alicloud:vpc/routeTableAttachment:RouteTableAttachment foo vtb-abc123456:vsw-abc123456

Example Usage

Basic Usage

using System.Collections.Generic;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var name = config.Get("name") ?? "route-table-attachment-example-name";
    var fooNetwork = new AliCloud.Vpc.Network("fooNetwork", new()
    {
        CidrBlock = "172.16.0.0/12",
    });

    var @default = AliCloud.GetZones.Invoke(new()
    {
        AvailableResourceCreation = "VSwitch",
    });

    var fooSwitch = new AliCloud.Vpc.Switch("fooSwitch", new()
    {
        VpcId = fooNetwork.Id,
        CidrBlock = "172.16.0.0/21",
        ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
    });

    var fooRouteTable = new AliCloud.Vpc.RouteTable("fooRouteTable", new()
    {
        VpcId = fooNetwork.Id,
        RouteTableName = name,
        Description = "route_table_attachment",
    });

    var fooRouteTableAttachment = new AliCloud.Vpc.RouteTableAttachment("fooRouteTableAttachment", new()
    {
        VswitchId = fooSwitch.Id,
        RouteTableId = fooRouteTable.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 := "route-table-attachment-example-name"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		fooNetwork, err := vpc.NewNetwork(ctx, "fooNetwork", &vpc.NetworkArgs{
			CidrBlock: pulumi.String("172.16.0.0/12"),
		})
		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, "fooSwitch", &vpc.SwitchArgs{
			VpcId:     fooNetwork.ID(),
			CidrBlock: pulumi.String("172.16.0.0/21"),
			ZoneId:    *pulumi.String(_default.Zones[0].Id),
		})
		if err != nil {
			return err
		}
		fooRouteTable, err := vpc.NewRouteTable(ctx, "fooRouteTable", &vpc.RouteTableArgs{
			VpcId:          fooNetwork.ID(),
			RouteTableName: pulumi.String(name),
			Description:    pulumi.String("route_table_attachment"),
		})
		if err != nil {
			return err
		}
		_, err = vpc.NewRouteTableAttachment(ctx, "fooRouteTableAttachment", &vpc.RouteTableAttachmentArgs{
			VswitchId:    fooSwitch.ID(),
			RouteTableId: fooRouteTable.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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("route-table-attachment-example-name");
        var fooNetwork = new Network("fooNetwork", NetworkArgs.builder()        
            .cidrBlock("172.16.0.0/12")
            .build());

        final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
            .availableResourceCreation("VSwitch")
            .build());

        var fooSwitch = new Switch("fooSwitch", SwitchArgs.builder()        
            .vpcId(fooNetwork.id())
            .cidrBlock("172.16.0.0/21")
            .zoneId(default_.zones()[0].id())
            .build());

        var fooRouteTable = new RouteTable("fooRouteTable", RouteTableArgs.builder()        
            .vpcId(fooNetwork.id())
            .routeTableName(name)
            .description("route_table_attachment")
            .build());

        var fooRouteTableAttachment = new RouteTableAttachment("fooRouteTableAttachment", RouteTableAttachmentArgs.builder()        
            .vswitchId(fooSwitch.id())
            .routeTableId(fooRouteTable.id())
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "route-table-attachment-example-name"
foo_network = alicloud.vpc.Network("fooNetwork", cidr_block="172.16.0.0/12")
default = alicloud.get_zones(available_resource_creation="VSwitch")
foo_switch = alicloud.vpc.Switch("fooSwitch",
    vpc_id=foo_network.id,
    cidr_block="172.16.0.0/21",
    zone_id=default.zones[0].id)
foo_route_table = alicloud.vpc.RouteTable("fooRouteTable",
    vpc_id=foo_network.id,
    route_table_name=name,
    description="route_table_attachment")
foo_route_table_attachment = alicloud.vpc.RouteTableAttachment("fooRouteTableAttachment",
    vswitch_id=foo_switch.id,
    route_table_id=foo_route_table.id)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "route-table-attachment-example-name";
const fooNetwork = new alicloud.vpc.Network("fooNetwork", {cidrBlock: "172.16.0.0/12"});
const default = alicloud.getZones({
    availableResourceCreation: "VSwitch",
});
const fooSwitch = new alicloud.vpc.Switch("fooSwitch", {
    vpcId: fooNetwork.id,
    cidrBlock: "172.16.0.0/21",
    zoneId: _default.then(_default => _default.zones?.[0]?.id),
});
const fooRouteTable = new alicloud.vpc.RouteTable("fooRouteTable", {
    vpcId: fooNetwork.id,
    routeTableName: name,
    description: "route_table_attachment",
});
const fooRouteTableAttachment = new alicloud.vpc.RouteTableAttachment("fooRouteTableAttachment", {
    vswitchId: fooSwitch.id,
    routeTableId: fooRouteTable.id,
});
configuration:
  name:
    type: string
    default: route-table-attachment-example-name
resources:
  fooNetwork:
    type: alicloud:vpc:Network
    properties:
      cidrBlock: 172.16.0.0/12
  fooSwitch:
    type: alicloud:vpc:Switch
    properties:
      vpcId: ${fooNetwork.id}
      cidrBlock: 172.16.0.0/21
      zoneId: ${default.zones[0].id}
  fooRouteTable:
    type: alicloud:vpc:RouteTable
    properties:
      vpcId: ${fooNetwork.id}
      routeTableName: ${name}
      description: route_table_attachment
  fooRouteTableAttachment:
    type: alicloud:vpc:RouteTableAttachment
    properties:
      vswitchId: ${fooSwitch.id}
      routeTableId: ${fooRouteTable.id}
variables:
  default:
    fn::invoke:
      Function: alicloud:getZones
      Arguments:
        availableResourceCreation: VSwitch

Create RouteTableAttachment Resource

new RouteTableAttachment(name: string, args: RouteTableAttachmentArgs, opts?: CustomResourceOptions);
@overload
def RouteTableAttachment(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         route_table_id: Optional[str] = None,
                         vswitch_id: Optional[str] = None)
@overload
def RouteTableAttachment(resource_name: str,
                         args: RouteTableAttachmentArgs,
                         opts: Optional[ResourceOptions] = 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.

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.

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

The RouteTableAttachment resource accepts the following input properties:

RouteTableId string

The route_table_id of the route table attachment, the field can't be changed.

VswitchId string

The vswitch_id of the route table attachment, the field can't be changed.

RouteTableId string

The route_table_id of the route table attachment, the field can't be changed.

VswitchId string

The vswitch_id of the route table attachment, the field can't be changed.

routeTableId String

The route_table_id of the route table attachment, the field can't be changed.

vswitchId String

The vswitch_id of the route table attachment, the field can't be changed.

routeTableId string

The route_table_id of the route table attachment, the field can't be changed.

vswitchId string

The vswitch_id of the route table attachment, the field can't be changed.

route_table_id str

The route_table_id of the route table attachment, the field can't be changed.

vswitch_id str

The vswitch_id of the route table attachment, the field can't be changed.

routeTableId String

The route_table_id of the route table attachment, the field can't be changed.

vswitchId String

The vswitch_id of the route table attachment, the field can't be changed.

Outputs

All input properties are implicitly available as output properties. Additionally, the RouteTableAttachment 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 str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

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,
        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.
The following state arguments are supported:
RouteTableId string

The route_table_id of the route table attachment, the field can't be changed.

VswitchId string

The vswitch_id of the route table attachment, the field can't be changed.

RouteTableId string

The route_table_id of the route table attachment, the field can't be changed.

VswitchId string

The vswitch_id of the route table attachment, the field can't be changed.

routeTableId String

The route_table_id of the route table attachment, the field can't be changed.

vswitchId String

The vswitch_id of the route table attachment, the field can't be changed.

routeTableId string

The route_table_id of the route table attachment, the field can't be changed.

vswitchId string

The vswitch_id of the route table attachment, the field can't be changed.

route_table_id str

The route_table_id of the route table attachment, the field can't be changed.

vswitch_id str

The vswitch_id of the route table attachment, the field can't be changed.

routeTableId String

The route_table_id of the route table attachment, the field can't be changed.

vswitchId String

The vswitch_id of the route table attachment, the field can't be changed.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.