Calls the DeleteVpc operation to delete a Virtual Private Cloud (VPC).
Operation description
When calling this operation to delete a VPC, note the following:
-
Before deleting a VPC, you must release or migrate all resources in the VPC, including vSwitches, cloud product instances, and high-availability virtual IP addresses (HAVIPs).
-
Only VPCs in the Available state can be deleted.
-
The DeleteVpc operation is asynchronous. After a request is sent, a request ID is returned, but the VPC is not immediately deleted. The deletion task continues in the background. You can call the DescribeVpcAttribute operation to query the deletion status of the VPC:
When the VPC is in the Deleting state, the VPC is being deleted.
When the specified VPC cannot be found, the VPC is deleted.
-
The DeleteVpc operation 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 to be deleted. |
vpc-bp1m7v25emi1h5mtc**** |
| RegionId |
string |
No |
The region ID of the VPC to be deleted. You can call the DescribeRegions operation to query region IDs. |
cn-hangzhou |
| ForceDelete |
boolean |
No |
Specifies whether to forcefully delete the VPC. Valid values:
The VPC can be forcefully deleted only when the following resources exist in the VPC:
|
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 be different 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. | |
| 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. | |
| 400 | DependencyViolation.CloudServiceResource | The VPC contains CloudServiceResource and cannot be deleted. | |
| 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. |
| 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.