Deletes a virtual private cloud (VPC).
Operation description
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).
-
You can delete only a VPC that is in the Available state.
-
The DeleteVpc operation is asynchronous. After you send the request, the system returns a request ID. However, the operation is still being performed in the system background. You can call the DescribeVpcAttribute operation to query the status of a VPC:
- 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 the DeleteVpc operation to delete a VPC within the specified period of time.
Debugging
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.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
vpc:DeleteVpc | delete | *VPC acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
VpcId | string | Yes | The ID of the VPC that you want to delete. | vpc-bp1m7v25emi1h5mtc**** |
RegionId | string | No | The ID of the region where the VPC is deployed. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
ForceDelete | boolean | No | Specifies whether to forcefully delete the VPC. Valid values:
You can forcefully delete a VPC in the following scenarios:
| false |
DryRun | boolean | No | Specifies whether to perform a dry run. Valid values:
| false |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}
Error codes
HTTP status code | 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 specified vSwitch is connected to 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 object is already 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. | Operations are too frequent and tasks conflict with each other. |
400 | InvalidAction | The VPC has been connected to the classic network ECS. Please cancel the connection before proceeding. | - |
400 | DependencyViolation.Ipv6Gateway | %s | - |
400 | IncorrectStatus.cbnStatus | Current CBN status does not support this operation. | The status of the CEN instance is invalid. |
400 | DependencyViolation.RouteTable | Specified object has dependent custom routeTable. | - |
400 | DependencyViolation.NetworkAcl | Specified object has dependent resources network acl. | The specified object is associated with a network ACL. |
400 | DependencyViolation.CloudServiceResource | %s | - |
400 | DependencyViolation.ClassicLinkInstance | Specified object has active classicLink instance. | - |
400 | System.ServiceBusy | System is busy, please try later. | - |
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. | - |
400 | DependencyViolation.Ipv4Gateway | The VPC cannot be deleted when it has ipv4Gateway. | The VPC cannot be deleted because an IPv4 gateway exists in the VPC. |
400 | DependencyViolation.GatewayRouteTable | Specified object has dependent resources gatewayRouteTable. | - |
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 specified VPC does not exist. |
404 | DependencyViolation.Instance | ClassicLink Instances exist in VPC. | Instances exist in the VPC and the VPC cannot be deleted. |
500 | InternalError | The request processing has failed due to some unknown error. | An unknown error occurred. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-10-28 | The Error code has changed | View Change Details |
2024-09-29 | The Error code has changed | View Change Details |
2024-07-24 | The Error code has changed | View Change Details |
2024-01-24 | The Error code has changed | View Change Details |
2023-09-25 | API Description Update. The Error code has changed | View Change Details |
2023-06-16 | The Error code has changed | View Change Details |
2023-03-07 | The Error code has changed. The request parameters of the API has changed | View Change Details |