Deletes a virtual private cloud (VPC).
Operation description
When you call this operation to delete a VPC, take note of the following items:
-
Before you delete a VPC, release or migrate all resources in the VPC, including vSwitches, cloud service instances, and high-availability virtual IP addresses.
-
Only VPCs in the Available state can be deleted.
-
DeleteVpc is an asynchronous operation. After you send a request, the system returns a request ID, but the VPC is not yet deleted. The deletion task runs in the background. You can call DescribeVpcAttribute to query the deletion status of the VPC:
If the VPC is in the Deleting state, the VPC is being deleted.
If the VPC cannot be found, the VPC is deleted.
-
DeleteVpc does not support concurrent deletion of the same VPC.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
vpc:DeleteVpc |
delete |
*VPC
|
|
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 region ID of the VPC that you want to delete. You can call DescribeRegions to query the region ID. |
cn-hangzhou |
| ForceDelete |
boolean |
No |
Specifies whether to force delete the VPC. Valid values:
You can force delete a VPC only when the VPC contains only the following resources:
|
false |
| DryRun |
boolean |
No |
Specifies whether to perform a dry run. Valid values:
|
false |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The ClientToken value can contain only ASCII characters. Note
If you do not specify this parameter, the system uses the RequestId of the API request as the ClientToken. The RequestId may differ for each API request. |
123e4567-e89b-12d3-a456-426655440000 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The request ID. |
||
| RequestId |
string |
The request ID. |
0ED8D006-F706-4D23-88ED-E11ED28DCAC0 |
Examples
Success response
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. | |
| 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 | |
| 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.RouteInterface | Specified object has dependent route interface . | |
| 400 | DependencyViolation.Tunnel | Specified object has dependent 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. | |
| 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 | Forbidden.VpcNotFound | Specified VPC can not found. | The specified VPC does not exist. |
| 400 | Forbbiden | Active custom route in 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 | 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.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. | A dependency conflict exists because custom route tables are present. |
| 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. |
| 400 | DependencyViolation.TransitRouter | Specified object has attached to Transit Router. | The specified resource is dependent on other resources and the current operation is not allowed. |
| 400 | DependencyViolation.Ipv6Gateway | The VPC contains IPv6Gateway and cannot be deleted. | The VPC cannot be deleted because it contains an IPv6 gateway. |
| 400 | DependencyViolation.CloudServiceResource | The VPC contains CloudServiceResource and cannot be deleted. | The VPC cannot be deleted because it contains EPS resources. |
| 400 | IncorrectStatus.VpcDnsHostnameStatus | The DnsHostname status of vpc does not support this operation. | The private domain name status of the current VPC does not support this operation. |
| 400 | OperationDenied.AttachedToECR | The operation is not allowed because the VPC is attached to ECR %s. | The operation is not allowed because the VPC is attached to ECR %s. |
| 400 | IncorrectStatus.RouteTableStatus | Route table [%s] status [%s] is not stable. Please try again later. | Route table [%s] status [%s] is not stable. Please try again later. |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | OperationDenied | The operation is not supported in this status. | |
| 404 | InvalidVpcId.NotFound | Specified VPC does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.