All Products
Search
Document Center

Virtual Private Cloud:DeleteVpc

更新時間:Nov 13, 2024

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
vpc:DeleteVpcdelete
  • VPC
    acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}
  • vpc:tag
none

Request parameters

ParameterTypeRequiredDescriptionExample
VpcIdstringYes

The ID of the VPC that you want to delete.

vpc-bp1m7v25emi1h5mtc****
RegionIdstringNo

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
ForceDeletebooleanNo

Specifies whether to forcefully delete the VPC. Valid values:

  • true: yes
  • false (default): no

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.
false
DryRunbooleanNo

Specifies whether to perform a dry run. Valid values:

  • true: performs a dry run. The system checks the required parameters, request syntax, and limits. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.
  • false (default): performs a dry run and sends the request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.
false

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400IncorrectStatus.VpcDhcpStatusThe 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.
400DependencyViolation.GatewayEndpointThe 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.
400IncorrectVpcStatusCurrent VPC status does not support this operation.This operation cannot be performed when the VPC is in the current state.
400DependencyViolation.RouteEntrySpecified object has dependent resourcesThe VPC cannot be deleted because custom routes exist in the VPC.
400DependencyViolation.InstanceSpecified object has dependent resourcesThe VPC is associated with a resource.
400DependencyViolation.VSwitchSpecified object has dependent resourcesvSwitches exist in the VPC and the VPC cannot be deleted. Delete the vSwitches and try again.
400DependencyViolation.SecurityGroupSpecified object has dependent resources SecurityGroup.Security groups exist in the VPC and the VPC cannot be deleted. Delete the security groups and try again.
400DependencyViolation.RouteInterfaceSpecified object has dependent route interface .The specified vSwitch is connected to a router interface and cannot be deleted.
400DependencyViolation.TunnelSpecified object has dependent tunnel.The VPC is associated with a tunnel.
400DependencyViolation.NatGatewaySpecified object has dependent resources NatGateway.NAT gateways exist in the VPC and the VPC cannot be deleted. Delete the NAT gateways and try again.
400DependencyViolation.RouterInterfaceSpecified object has dependent resources RouterInterface.The object is already associated with a router interface.
400Forbidden.VpcNotFoundSpecified VPC can not found.The specified VPC does not exist.
400ForbbidenActive custom route in vpc.You must add a custom route entry to the VPC.
400TaskConflictThe eip operate too frequent, TaskConflict.Operations are too frequent and tasks conflict with each other.
400InvalidActionThe VPC has been connected to the classic network ECS. Please cancel the connection before proceeding.-
400DependencyViolation.Ipv6Gateway%s-
400IncorrectStatus.cbnStatusCurrent CBN status does not support this operation.The status of the CEN instance is invalid.
400DependencyViolation.RouteTableSpecified object has dependent custom routeTable.-
400DependencyViolation.NetworkAclSpecified object has dependent resources network acl.The specified object is associated with a network ACL.
400DependencyViolation.CloudServiceResource%s-
400DependencyViolation.ClassicLinkInstanceSpecified object has active classicLink instance.-
400System.ServiceBusySystem is busy, please try later.-
400DependencyViolation.DhcpOptionsSetThe VPC cannot be deleted when it is associated with dhcpOptionsSet.The VPC cannot be deleted when it is associated with dhcpOptionsSet.
400InvalidRegionId.NotFoundThe specified region is not found.The specified region does not exist.
400DependencyViolation.CustomRouteTableCustomRouteTable already exists.-
400DependencyViolation.Ipv4GatewayThe VPC cannot be deleted when it has ipv4Gateway.The VPC cannot be deleted because an IPv4 gateway exists in the VPC.
400DependencyViolation.GatewayRouteTableSpecified object has dependent resources gatewayRouteTable.-
400OperationDenied.VpcPeerExistsThe operation is not allowed because the VpcPeer exists.The VPC has a VPC peering connection.
400DependencyViolation.AppAccessSpecified object has dependent resources app access.The VPC has a reverse access and cannot be deleted.
400DependencyViolation.OppositeRouterInterfaceFailed 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.
403OperationDeniedThe operation is not supported in this status.The status of the VPC is invalid and the operation cannot be performed.
403OperationDeniedThe snapshot creation for the specified disk is not finished yet.The snapshot of the specified disk is being created.
404InvalidVpcId.NotFoundSpecified VPC does not exist.The specified VPC does not exist.
404DependencyViolation.InstanceClassicLink Instances exist in VPC.Instances exist in the VPC and the VPC cannot be deleted.
500InternalErrorThe 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 timeSummary of changesOperation
2024-10-28The Error code has changedView Change Details
2024-09-29The Error code has changedView Change Details
2024-07-24The Error code has changedView Change Details
2024-01-24The Error code has changedView Change Details
2023-09-25API Description Update. The Error code has changedView Change Details
2023-06-16The Error code has changedView Change Details
2023-03-07The Error code has changed. The request parameters of the API has changedView Change Details