All Products
Search
Document Center

:DeleteVpc

最終更新日:Aug 28, 2023

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 all resources deployed in the VPC are released or removed, such as vSwitches, instances, and high-availability virtual IP addresses (HAVIPs).
  • Only VPCs in the Available state can be deleted.
  • DeleteVpc 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 DescribeVpcAttribute to query the status of the task:
    • If the VPC is in the Deleting state, the VPC is being deleted.
    • If you cannot query the VPC, the VPC is deleted.
  • You cannot repeatedly call DeleteVpc within a specific time period.

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.

ForceDelete Boolean No false

Specifies whether to forcefully delete the VPC. Valid values:

  • true
  • false (default)

You can forcefully delete a VPC in the following scenarios:

  • Only an IPv4 gateway and routes that point to the IPv4 gateway exist in the VPC.
  • Only an IPv6 gateway and routes that point to the IPv6 gateway exist in the VPC.
DryRun Boolean No false

Specifies whether to perform only a dry run, without performing the actual request. Valid values:

  • true: performs only a dry run. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the dry run, an error message is returned. If the request passes the check, the DryRunOperation error code is returned.
  • false (default): performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.

Response parameters

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

The request ID.

Examples

Sample requests

http(s)://[Endpoint]/?Action=DeleteVpc
&VpcId=vpc-bp1m7v25emi1h5mtc****
&RegionId=cn-hangzhou
&ForceDelete=false
&DryRun=false
&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 IncorrectStatus.VpcDhcpStatus The DhcpOptionsSet status of vpc does not support this operation. You cannot delete the VPC when the DHCP options set of the VPC is in the current state.
400 DependencyViolation.GatewayEndpoint The VPC contains endpoints and cannot be deleted. The VPC contains endpoints and cannot be deleted. Delete the endpoints in the VPC and then delete the VPC.
400 IncorrectVpcStatus Current VPC status does not support this operation. This operation cannot be performed when the VPC is in the current state.
400 DependencyViolation.RouteEntry Specified object has dependent resources The VPC cannot be deleted because custom routes exist in the VPC.
400 DependencyViolation.Instance Specified object has dependent resources The VPC is associated with a resource.
400 DependencyViolation.VSwitch Specified object has dependent resources 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. 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 vSwitch is associated with a router interface and cannot be deleted.
400 DependencyViolation.Tunnel Specified object has dependent tunnel. The VPC is associated with a tunnel.
400 DependencyViolation.NatGateway Specified object has dependent resources NatGateway. 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 VPC is associated with a router interface.
400 Forbidden.VpcNotFound Specified VPC can not found. The specified VPC does not exist.
400 Forbbiden Active custom route in vpc. You must add a custom route entry to the VPC.
400 TaskConflict The eip operate too frequent, TaskConflict. The operations are too frequent and tasks conflict with each other.
400 IncorrectStatus.cbnStatus Current CBN status does not support this operation. The status of the CEN instance is invalid.
400 DependencyViolation.NetworkAcl Specified object has dependent resources network acl. The specified object is associated with a network ACL.
400 DependencyViolation.DhcpOptionsSet The VPC cannot be deleted when it is associated with dhcpOptionsSet. The VPC cannot be deleted when it is associated with dhcpOptionsSet.
400 InvalidRegionId.NotFound The specified region is not found. The specified region does not exist.
400 DependencyViolation.CustomRouteTable CustomRouteTable already exists. Custom route tables exist in the VPC.
400 DependencyViolation.Ipv4Gateway The VPC cannot be deleted when it has ipv4Gateway. An IPv4 gateway exists in the VPC and the VPC cannot be deleted.
400 OperationDenied.VpcPeerExists The operation is not allowed because the VpcPeer exists. The VPC has a VPC peering connection.
400 DependencyViolation.AppAccess Specified object has dependent resources app access. The VPC has a reverse access and cannot be deleted.
400 DependencyViolation.OppositeRouterInterface Failed to delete the VPC because it has peer router interfaces. The VPC failed to be deleted because a peer router interface exists in the VPC.
403 OperationDenied The operation is not supported in this status. 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 snapshot of the specified disk is being created.
404 InvalidVpcId.NotFound Specified VPC does not exist. The VPC does not exist.
500 InternalError The request processing has failed due to some unknown error. Some unknown errors occurred.

For a list of error codes, see Service error codes.