All Products
Search
Document Center

Virtual Private Cloud:CreateVSwitch

Last Updated:Mar 04, 2024

Creates a vSwitch.

Operation description

When you call this operation, take note of the following limits:

  • You can create at most 150 vSwitches in a virtual private cloud (VPC).

  • The first IP address and last three IP addresses of each vSwitch CIDR block are reserved. For example, if the CIDR block of a vSwitch is 192.168.1.0/24, the IP addresses 192.168.1.0, 192.168.1.253, 192.168.1.254, and 192.168.1.255 are reserved.

  • The number of instances in a vSwitch cannot exceed the remaining capacity of the VPC. The remaining capacity is the difference between 15,000 and the current number of instances.

  • Each instance can belong to only one vSwitch.

  • vSwitches do not support multicast or broadcast.

  • After you create a vSwitch, you cannot modify its CIDR block.

  • CreateVSwitch is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call DescribeVSwitchAttributes to query the status of the task.

    • If the vSwitch is in the Pending state, the vSwitch is being configured.
    • If the vSwitch is in the Available state, the vSwitch is available.
  • You cannot repeatedly call the CreateVSwitch operation to create a vSwitch in a VPC within the specified period of time.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
vpc:CreateVSwitchWrite
  • VPC
    acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}
  • VSwitch
    acs:vpc:{#regionId}:{#accountId}:vswitch/*
  • vpc:tag
none

Request parameters

ParameterTypeRequiredDescriptionExample
Tagobject []No

The tag of the resource.

KeystringNo

The tag key. You can specify at most 20 tag keys. The tag key cannot be an empty string.

The tag key can be at most 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

FinanceJoshua
ValuestringNo

The tag value. You can specify at most 20 tag values. The tag value can be an empty string.

The tag value can be up to 128 characters in length, but cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

FinanceDept
ZoneIdstringYes

The zone ID of the vSwitch.

You can call the DescribeZones operation to query the most recent zone list.

cn-hangzhou-b
RegionIdstringNo

The region ID of the vSwitch.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
CidrBlockstringYes

The CIDR block of the vSwitch. Take note of the following limits:

  • The subnet mask of the CIDR block must be 16 to 29 bits in length.
  • The CIDR block of the vSwitch must fall within the CIDR block of the VPC to which the vSwitch belongs.
  • The CIDR block of a vSwitch cannot be the same as the destination CIDR block in a route entry of the VPC. However, it can be a subset of the destination CIDR block.
172.16.0.0/24
Ipv6CidrBlockintegerNo

The last eight bits of the IPv6 CIDR block of the vSwitch. Valid values: 0 to 255.

12
VpcIdstringYes

The ID of the VPC where you want to create the vSwitch.

vpc-257gqcdfvx6n****
VSwitchNamestringNo

The name of the vSwitch.

The name must be 1 to 128 characters in length, and cannot start with http:// or https://.

vSwitch-1
DescriptionstringNo

The description of the vSwitch.

The description must be 1 to 256 characters in length and cannot start with http:// or https://.

vSwitch
ClientTokenstringNo

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the value, but you must make sure that it is unique among all requests. The token can contain only ASCII characters.

Note If you do not specify this parameter, ClientToken is set to the value of RequestId. The value of RequestId may be different for each API request.
0c593ea1-3bea-11e9-b96b-88e9fe63****
VpcIpv6CidrBlockstringNo

The IPv6 CIDR block of the VPC.

2408:XXXX:0:6a::/56

Response parameters

ParameterTypeDescriptionExample
object

The returned data.

VSwitchIdstring

The ID of the vSwitch.

vsw-25navfgbue4g****
RequestIdstring

The ID of the request.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

Examples

Sample success responses

JSONformat

{
  "VSwitchId": "vsw-25navfgbue4g****",
  "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}

Error codes

HTTP status codeError codeError messageDescription
400OperationFailed.ResourceConflictvpc only support one cloud box.-
400OperationFailed.IdempotentTokenProcessingAction is processing.-
400InvalidDescription.MalformedInvalid description.-
400InvalidVSwitchName.MalformedSpecified virtual switch name is not valid.The format of the specified vSwitch name is invalid. Specify the name in the valid format.
400InvalidVSwitchDiscription.MalformedSpecified virtual switch description is not valid.The vSwitch description is invalid.
400Abs.Vpc.InvalidDescription.MalformedSpecified virtual switch name is not valid.-
400MissingParam.vpcIdThe parameter vpcId is mandatory.The vpcId parameter is required.
400ResourceNotAvailableResource you requested is not available in this region or zone.You cannot create a vSwitch in the current region or zone.
400InvalidParameterSpecified CIDR block is not valid in VPC.The CIDR block does not fall within the VPC CIDR block.
400InvalidCidrBlock.OverlappedSpecified CIDR block overlapped with other subnets.The vSwitch CIDR block overlaps with another vSwitch CIDR block or with the destination CIDR block of a custom route entry. Try a different CIDR block that is not in use.
400InvalidCidrBlock.OverlappedSpecified CIDR block overlapped with other entry.The specified CIDR block overlaps the CIDR block of another VPC or a custom routing destination. Select a CIDR block that is not used.
400QuotaExceeded.VSwitchVirtual switch quota exceeded.The number of vSwitches has reached the upper limit. Reduce the number of vSwitches and try again later.
400IncorrectRouteEntryStatusSome route entry status blocked this operation.The operation is not supported because the route table contains routes in the Pending or Modifying state.
400IncorrectVSwitchStatusSome virtual switch is modifying within the same VPC.Multiple vSwitches are in the Modifying state in the same VPC. Try again later.
400InvalidCirdrBlock.MaskLengthSpecified CIDR block is not valid .Invalid CIDR block.
400IncorrectVpcStatusCurrent VPC status does not support this operation.This operation cannot be performed when the VPC is in the current state.
400CreateVSwitch.IncorrectStatus.cbnStatusCurrent CBN status does not support this operation.You cannot create a vSwitch when the CEN instance is in the current state.
400InvalidCidrBlock.MalformedSpecified CIDR block is not valid.The format of the CIDR block is invalid.
400MissingParameterMiss mandatory parameter.Some required parameters are not specified. Specify all required parameters and try again.
400IncorrectVSwitchStatusVSwitch Creation simultaneously is not supported.The system failed to create the vSwitch and one or more vSwitches that belong to the VPC are in the Creating state.
400TaskConflictThe operation is too frequent, TaskConflict.The system is unavailable. Try again later.
400VPC.SWITCH.RULE.QUOTA.NOT.EXISTSvSwitch quota rule not exists.-
400Forbidden.VpcNotFoundSpecified VPC can not found.The specified VPC does not exist.
400RouteConflict.AlreadyExistRoute conflict exists in routing table.Route conflicts exist in the route table.
400OperationFailed.CidrAcrossClassic link instance cidr must not across.-
400Duplicated.ClientToken%s-
400OperationFailed.Ipv6CidrBlockExisted%s-
400IllegalParam.Ipv6CidrBlock%s-
400OperationFailed.VpcIpv6Disabled%s-
400IncorrectStatus.cbnStatusCurrent CBN status does not support this operation.The status of the CEN instance is invalid.
400OperationFailed.NotifyCenCreateFailed to notify cen when create vswitch.-
400OperationFailed.DistibuteLockDistibute lock fail.-
400UnsupportedFeature.CloudBoxIpv6The IPv6 feature is not supported by cloud box.You cannot create an IPv6 address for a CloudBox instance.
400OperationDenied.VpcPeerExistThe operation is not allowed because the VPC peer exists.The operation failed because VPC peering connections exist.
400OperationDenied.CenAttachedThe operation is not allowed because the VPC is attached to CEN.The operation is not allowed because the VPC is attached to a CEN instance.
400OperationDenied.NatgwExistThe operation is not allowed because the NAT gateway exists in VPC.The operation is not allowed because NAT gateways exist in the VPC.
400MissingParam.Ipv6CidrBlockThe parameter Ipv6CidrBlock is mandatory.The Ipv6CidrBlock parameter is required.
400IllegalParam.VpcIpv6CidrBlock%s-
400OperationDenied.OtherSubnetCreatingThe operation is not allowed because the other VSwitch is creating.-
400OperationDenied.VpcPeerExistsThe operation is not allowed because the VpcPeer exists.The VPC has a VPC peering connection.
404Invalid.NotExistwitch mask rule not exists.-
404InvalidStatus.RouteEntryRouteEntry status error.-
404InvalidZoneId.NotFoundSpecified zone does not exist.The zone ID is invalid.
404InvalidVpcId.NotFoundSpecified VPC does not exist.The specified VPC does not exist.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-17The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 400 change
    delete Error Codes: 404
2023-09-06The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 404
2023-07-05API Description Update. The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
API DescriptionAPI Description Update.
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 404
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: Tag