Deletes a virtual private cloud (VPC).

Usage notes

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

  • Before you delete a VPC, make sure that you have released or removed all resources deployed in the VPC, such as vSwitches, instances, and high-availability virtual IP addresses (HAVIPs).
  • You can delete only a VPC that is in the Available state.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DeleteVpc

The operation that you want to perform. Set the value to DeleteVpc.

VpcId String Yes vpc-bp1m7v25emi1h5mtc****

The ID of the VPC that you want to delete.

RegionId String No cn-hangzhou

The ID of the region where the VPC is deployed.

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

Response parameters

Parameter Type Example Description
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=DeleteVpc
&ResourceOwnerId=111
&VpcId=vpc-bp1m7v25emi1h5mtc****
&RegionId=cn-hangzhou
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DeleteVpcResponse>
    <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</DeleteVpcResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}

Error codes

HttpCode Error code Error message Description
400 DependencyViolation.GatewayEndpoint The VPC contains endpoints and cannot be deleted. The error message returned because endpoints exist in the VPC. Delete the endpoints before you delete the VPC.
400 IncorrectVpcStatus Current VPC status does not support this operation. The error message returned because this operation cannot be performed while the VPC is in the current state.
400 DependencyViolation.RouteEntry Specified object has dependent resources The error message returned because custom route entries exist in the VPC and the VPC cannot be deleted.
400 DependencyViolation.Instance Specified object has dependent resources The error message returned because the VPC is associated with a resource.
400 DependencyViolation.VSwitch Specified object has dependent resources The error message returned because vSwitches exist in the VPC and the VPC cannot be deleted. Delete the vSwitches and try again.
400 DependencyViolation.SecurityGroup Specified object has dependent resources SecurityGroup. The error message returned because security groups exist in the VPC and the VPC cannot be deleted. Delete the security groups and try again.
400 DependencyViolation.RouteInterface Specified object has dependent route interface . The error message returned because the vSwitch is associated with a router interface and cannot be deleted.
400 DependencyViolation.Tunnel Specified object has dependent tunnel. The error message returned because the VPC is associated with a tunnel.
400 DependencyViolation.NatGateway Specified object has dependent resources NatGateway. The error message returned because NAT gateways exist in the VPC and the VPC cannot be deleted. Delete the NAT gateways and try again.
400 DependencyViolation.RouterInterface Specified object has dependent resources RouterInterface. The error message returned because the VPC is associated with a router interface.
400 Forbidden.VpcNotFound Specified VPC can not found. The error message returned because the specified VPC does not exist.
400 Forbbiden Active custom route in vpc. The error message returned because you must add a custom route entry to the VPC.
400 IncorrectStatus.cbnStatus Current CBN status does not support this operation. The error message returned because the status of the Cloud Enterprise Network (CEN) instance is invalid.
400 DependencyViolation.DhcpOptionsSet The VPC cannot be deleted when it is associated with dhcpOptionsSet. The error message returned because DHCP options sets exist in the VPC and the VPC cannot be deleted. Delete the DHCP options sets and try again.
400 InvalidRegionId.NotFound The specified region is not found. The error message returned because the specified region does not exist.
400 DependencyViolation.CustomRouteTable CustomRouteTable already exists. The error message returned because custom route tables exist in the VPC.
403 OperationDenied The operation is not supported in this status. The error message returned because the status of the VPC is invalid and the operation cannot be performed.
403 OperationDenied The snapshot creation for the specified disk is not finished yet. The error message returned because the snapshot of the specified disk is being created.
404 InvalidVpcId.NotFound Specified VPC does not exist. The error message returned because the specified VPC does not exist.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an unknown error occurred.

For a list of error codes, visit the API Error Center.