1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. ens
  5. Vswitch
Alibaba Cloud v3.75.0 published on Friday, Mar 7, 2025 by Pulumi

alicloud.ens.Vswitch

Explore with Pulumi AI

Provides a ENS Vswitch resource.

For information about ENS Vswitch and how to use it, see What is Vswitch.

NOTE: Available since v1.213.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 _default = new alicloud.ens.Network("default", {
    networkName: name,
    description: name,
    cidrBlock: "192.168.2.0/24",
    ensRegionId: "cn-chenzhou-telecom_unicom_cmcc",
});
const defaultVswitch = new alicloud.ens.Vswitch("default", {
    description: name,
    cidrBlock: "192.168.2.0/24",
    vswitchName: name,
    ensRegionId: "cn-chenzhou-telecom_unicom_cmcc",
    networkId: _default.id,
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "terraform-example"
default = alicloud.ens.Network("default",
    network_name=name,
    description=name,
    cidr_block="192.168.2.0/24",
    ens_region_id="cn-chenzhou-telecom_unicom_cmcc")
default_vswitch = alicloud.ens.Vswitch("default",
    description=name,
    cidr_block="192.168.2.0/24",
    vswitch_name=name,
    ens_region_id="cn-chenzhou-telecom_unicom_cmcc",
    network_id=default.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ens"
	"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
		}
		_default, err := ens.NewNetwork(ctx, "default", &ens.NetworkArgs{
			NetworkName: pulumi.String(name),
			Description: pulumi.String(name),
			CidrBlock:   pulumi.String("192.168.2.0/24"),
			EnsRegionId: pulumi.String("cn-chenzhou-telecom_unicom_cmcc"),
		})
		if err != nil {
			return err
		}
		_, err = ens.NewVswitch(ctx, "default", &ens.VswitchArgs{
			Description: pulumi.String(name),
			CidrBlock:   pulumi.String("192.168.2.0/24"),
			VswitchName: pulumi.String(name),
			EnsRegionId: pulumi.String("cn-chenzhou-telecom_unicom_cmcc"),
			NetworkId:   _default.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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 @default = new AliCloud.Ens.Network("default", new()
    {
        NetworkName = name,
        Description = name,
        CidrBlock = "192.168.2.0/24",
        EnsRegionId = "cn-chenzhou-telecom_unicom_cmcc",
    });

    var defaultVswitch = new AliCloud.Ens.Vswitch("default", new()
    {
        Description = name,
        CidrBlock = "192.168.2.0/24",
        VswitchName = name,
        EnsRegionId = "cn-chenzhou-telecom_unicom_cmcc",
        NetworkId = @default.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ens.Network;
import com.pulumi.alicloud.ens.NetworkArgs;
import com.pulumi.alicloud.ens.Vswitch;
import com.pulumi.alicloud.ens.VswitchArgs;
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 default_ = new Network("default", NetworkArgs.builder()
            .networkName(name)
            .description(name)
            .cidrBlock("192.168.2.0/24")
            .ensRegionId("cn-chenzhou-telecom_unicom_cmcc")
            .build());

        var defaultVswitch = new Vswitch("defaultVswitch", VswitchArgs.builder()
            .description(name)
            .cidrBlock("192.168.2.0/24")
            .vswitchName(name)
            .ensRegionId("cn-chenzhou-telecom_unicom_cmcc")
            .networkId(default_.id())
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: terraform-example
resources:
  default:
    type: alicloud:ens:Network
    properties:
      networkName: ${name}
      description: ${name}
      cidrBlock: 192.168.2.0/24
      ensRegionId: cn-chenzhou-telecom_unicom_cmcc
  defaultVswitch:
    type: alicloud:ens:Vswitch
    name: default
    properties:
      description: ${name}
      cidrBlock: 192.168.2.0/24
      vswitchName: ${name}
      ensRegionId: cn-chenzhou-telecom_unicom_cmcc
      networkId: ${default.id}
Copy

Create Vswitch Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Vswitch(name: string, args: VswitchArgs, opts?: CustomResourceOptions);
@overload
def Vswitch(resource_name: str,
            args: VswitchArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def Vswitch(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            cidr_block: Optional[str] = None,
            ens_region_id: Optional[str] = None,
            description: Optional[str] = None,
            network_id: Optional[str] = None,
            vswitch_name: Optional[str] = None)
func NewVswitch(ctx *Context, name string, args VswitchArgs, opts ...ResourceOption) (*Vswitch, error)
public Vswitch(string name, VswitchArgs args, CustomResourceOptions? opts = null)
public Vswitch(String name, VswitchArgs args)
public Vswitch(String name, VswitchArgs args, CustomResourceOptions options)
type: alicloud:ens:Vswitch
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. VswitchArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. VswitchArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. VswitchArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. VswitchArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. VswitchArgs
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 vswitchResource = new AliCloud.Ens.Vswitch("vswitchResource", new()
{
    CidrBlock = "string",
    EnsRegionId = "string",
    Description = "string",
    NetworkId = "string",
    VswitchName = "string",
});
Copy
example, err := ens.NewVswitch(ctx, "vswitchResource", &ens.VswitchArgs{
	CidrBlock:   pulumi.String("string"),
	EnsRegionId: pulumi.String("string"),
	Description: pulumi.String("string"),
	NetworkId:   pulumi.String("string"),
	VswitchName: pulumi.String("string"),
})
Copy
var vswitchResource = new Vswitch("vswitchResource", VswitchArgs.builder()
    .cidrBlock("string")
    .ensRegionId("string")
    .description("string")
    .networkId("string")
    .vswitchName("string")
    .build());
Copy
vswitch_resource = alicloud.ens.Vswitch("vswitchResource",
    cidr_block="string",
    ens_region_id="string",
    description="string",
    network_id="string",
    vswitch_name="string")
Copy
const vswitchResource = new alicloud.ens.Vswitch("vswitchResource", {
    cidrBlock: "string",
    ensRegionId: "string",
    description: "string",
    networkId: "string",
    vswitchName: "string",
});
Copy
type: alicloud:ens:Vswitch
properties:
    cidrBlock: string
    description: string
    ensRegionId: string
    networkId: string
    vswitchName: string
Copy

Vswitch 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 Vswitch resource accepts the following input properties:

CidrBlock
This property is required.
Changes to this property will trigger replacement.
string
The CIDR block of the vSwitch.
EnsRegionId
This property is required.
Changes to this property will trigger replacement.
string
ENS Region ID.
Description string
The description of the vSwitch.
NetworkId Changes to this property will trigger replacement. string
The ID of the network to which the vSwitch that you want to create belongs.
VswitchName string
The name of the vSwitch.
CidrBlock
This property is required.
Changes to this property will trigger replacement.
string
The CIDR block of the vSwitch.
EnsRegionId
This property is required.
Changes to this property will trigger replacement.
string
ENS Region ID.
Description string
The description of the vSwitch.
NetworkId Changes to this property will trigger replacement. string
The ID of the network to which the vSwitch that you want to create belongs.
VswitchName string
The name of the vSwitch.
cidrBlock
This property is required.
Changes to this property will trigger replacement.
String
The CIDR block of the vSwitch.
ensRegionId
This property is required.
Changes to this property will trigger replacement.
String
ENS Region ID.
description String
The description of the vSwitch.
networkId Changes to this property will trigger replacement. String
The ID of the network to which the vSwitch that you want to create belongs.
vswitchName String
The name of the vSwitch.
cidrBlock
This property is required.
Changes to this property will trigger replacement.
string
The CIDR block of the vSwitch.
ensRegionId
This property is required.
Changes to this property will trigger replacement.
string
ENS Region ID.
description string
The description of the vSwitch.
networkId Changes to this property will trigger replacement. string
The ID of the network to which the vSwitch that you want to create belongs.
vswitchName string
The name of the vSwitch.
cidr_block
This property is required.
Changes to this property will trigger replacement.
str
The CIDR block of the vSwitch.
ens_region_id
This property is required.
Changes to this property will trigger replacement.
str
ENS Region ID.
description str
The description of the vSwitch.
network_id Changes to this property will trigger replacement. str
The ID of the network to which the vSwitch that you want to create belongs.
vswitch_name str
The name of the vSwitch.
cidrBlock
This property is required.
Changes to this property will trigger replacement.
String
The CIDR block of the vSwitch.
ensRegionId
This property is required.
Changes to this property will trigger replacement.
String
ENS Region ID.
description String
The description of the vSwitch.
networkId Changes to this property will trigger replacement. String
The ID of the network to which the vSwitch that you want to create belongs.
vswitchName String
The name of the vSwitch.

Outputs

All input properties are implicitly available as output properties. Additionally, the Vswitch resource produces the following output properties:

CreateTime string
The time when the VPC was created.
Id string
The provider-assigned unique ID for this managed resource.
Status string
The status of the vSwitch.
CreateTime string
The time when the VPC was created.
Id string
The provider-assigned unique ID for this managed resource.
Status string
The status of the vSwitch.
createTime String
The time when the VPC was created.
id String
The provider-assigned unique ID for this managed resource.
status String
The status of the vSwitch.
createTime string
The time when the VPC was created.
id string
The provider-assigned unique ID for this managed resource.
status string
The status of the vSwitch.
create_time str
The time when the VPC was created.
id str
The provider-assigned unique ID for this managed resource.
status str
The status of the vSwitch.
createTime String
The time when the VPC was created.
id String
The provider-assigned unique ID for this managed resource.
status String
The status of the vSwitch.

Look up Existing Vswitch Resource

Get an existing Vswitch 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?: VswitchState, opts?: CustomResourceOptions): Vswitch
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cidr_block: Optional[str] = None,
        create_time: Optional[str] = None,
        description: Optional[str] = None,
        ens_region_id: Optional[str] = None,
        network_id: Optional[str] = None,
        status: Optional[str] = None,
        vswitch_name: Optional[str] = None) -> Vswitch
func GetVswitch(ctx *Context, name string, id IDInput, state *VswitchState, opts ...ResourceOption) (*Vswitch, error)
public static Vswitch Get(string name, Input<string> id, VswitchState? state, CustomResourceOptions? opts = null)
public static Vswitch get(String name, Output<String> id, VswitchState state, CustomResourceOptions options)
resources:  _:    type: alicloud:ens:Vswitch    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
CidrBlock Changes to this property will trigger replacement. string
The CIDR block of the vSwitch.
CreateTime string
The time when the VPC was created.
Description string
The description of the vSwitch.
EnsRegionId Changes to this property will trigger replacement. string
ENS Region ID.
NetworkId Changes to this property will trigger replacement. string
The ID of the network to which the vSwitch that you want to create belongs.
Status string
The status of the vSwitch.
VswitchName string
The name of the vSwitch.
CidrBlock Changes to this property will trigger replacement. string
The CIDR block of the vSwitch.
CreateTime string
The time when the VPC was created.
Description string
The description of the vSwitch.
EnsRegionId Changes to this property will trigger replacement. string
ENS Region ID.
NetworkId Changes to this property will trigger replacement. string
The ID of the network to which the vSwitch that you want to create belongs.
Status string
The status of the vSwitch.
VswitchName string
The name of the vSwitch.
cidrBlock Changes to this property will trigger replacement. String
The CIDR block of the vSwitch.
createTime String
The time when the VPC was created.
description String
The description of the vSwitch.
ensRegionId Changes to this property will trigger replacement. String
ENS Region ID.
networkId Changes to this property will trigger replacement. String
The ID of the network to which the vSwitch that you want to create belongs.
status String
The status of the vSwitch.
vswitchName String
The name of the vSwitch.
cidrBlock Changes to this property will trigger replacement. string
The CIDR block of the vSwitch.
createTime string
The time when the VPC was created.
description string
The description of the vSwitch.
ensRegionId Changes to this property will trigger replacement. string
ENS Region ID.
networkId Changes to this property will trigger replacement. string
The ID of the network to which the vSwitch that you want to create belongs.
status string
The status of the vSwitch.
vswitchName string
The name of the vSwitch.
cidr_block Changes to this property will trigger replacement. str
The CIDR block of the vSwitch.
create_time str
The time when the VPC was created.
description str
The description of the vSwitch.
ens_region_id Changes to this property will trigger replacement. str
ENS Region ID.
network_id Changes to this property will trigger replacement. str
The ID of the network to which the vSwitch that you want to create belongs.
status str
The status of the vSwitch.
vswitch_name str
The name of the vSwitch.
cidrBlock Changes to this property will trigger replacement. String
The CIDR block of the vSwitch.
createTime String
The time when the VPC was created.
description String
The description of the vSwitch.
ensRegionId Changes to this property will trigger replacement. String
ENS Region ID.
networkId Changes to this property will trigger replacement. String
The ID of the network to which the vSwitch that you want to create belongs.
status String
The status of the vSwitch.
vswitchName String
The name of the vSwitch.

Import

ENS Vswitch can be imported using the id, e.g.

$ pulumi import alicloud:ens/vswitch:Vswitch example <id>
Copy

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.