All Products
Search
Document Center

Virtual Private Cloud:DeleteVpc

Last Updated:Jun 19, 2026

Memanggil operasi DeleteVpc untuk menghapus Virtual Private Cloud (VPC).

Deskripsi operasi

Saat memanggil operasi ini untuk menghapus VPC, perhatikan hal berikut:

  • Sebelum menghapus VPC, Anda harus merilis atau memigrasi semua Sumber daya di VPC, termasuk vSwitch, instans produk cloud, dan alamat IP virtual ketersediaan tinggi (HAVIP).

  • Hanya VPC dalam status Available yang dapat dihapus.

  • Operasi DeleteVpc bersifat asinkron. Setelah permintaan dikirim, ID permintaan akan dikembalikan, tetapi VPC tidak langsung dihapus. Tugas penghapusan berlanjut di latar belakang. Anda dapat memanggil operasi DescribeVpcAttribute untuk mengkueri status penghapusan VPC:

    • Saat VPC berada dalam status Deleting, VPC sedang dihapus.

    • Saat VPC yang ditentukan tidak dapat ditemukan, VPC telah dihapus.

  • Operasi DeleteVpc tidak mendukung penghapusan bersamaan untuk VPC yang sama.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

vpc:DeleteVpc

delete

*VPC

acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}

  • vpc:tag
None

Parameter permintaan

Parameter

Type

Required

Description

Example

VpcId

string

Yes

ID VPC yang akan dihapus.

vpc-bp1m7v25emi1h5mtc****

RegionId

string

No

ID wilayah VPC yang akan dihapus.

Anda dapat memanggil operasi DescribeRegions untuk mengkueri ID wilayah.

cn-hangzhou

ForceDelete

boolean

No

Apakah akan menghapus VPC secara paksa. Nilai valid:

  • true: Menghapus VPC secara paksa.

  • false (default): Tidak menghapus VPC secara paksa.

VPC hanya dapat dihapus secara paksa jika Sumber daya berikut ada di VPC:

  • VPC hanya berisi gerbang IPv4 entri rute yang mengarah ke gerbang IPv4.

  • VPC hanya berisi gerbang IPv6 entri rute yang mengarah ke gerbang IPv6.

false

DryRun

boolean

No

Apakah akan menjalankan dry run. Nilai valid:

  • true: Menjalankan dry run tanpa benar-benar menghapus VPC. Sistem memeriksa apakah parameter yang diperlukan telah diatur, format permintaan valid, dan batasan bisnis terpenuhi. Jika pemeriksaan gagal, error yang sesuai akan dikembalikan. Jika pemeriksaan berhasil, kode kesalahan DryRunOperation akan dikembalikan.

  • false (default): Menjalankan dry run dan mengirimkan permintaan. Jika pemeriksaan berhasil, kode status HTTP 2xx akan dikembalikan, dan VPC langsung dihapus.

false

ClientToken

string

No

Token klien yang digunakan untuk memastikan idempotensi permintaan.

Anda dapat menggunakan klien untuk menghasilkan token, tetapi Anda harus memastikan bahwa token tersebut unik di antara permintaan yang berbeda. Nilai ClientToken hanya dapat berisi karakter ASCII.

Catatan

Jika Anda tidak menentukan parameter ini, sistem menggunakan RequestId dari permintaan API sebagai ClientToken. RequestId mungkin berbeda untuk setiap permintaan API.

123e4567-e89b-12d3-a456-426655440000

Elemen respons

Element

Type

Description

Example

object

ID permintaan.

RequestId

string

ID permintaan.

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

Contoh

Respons sukses

JSONformat

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

Kode kesalahan

HTTP status code

Error code

Error message

Description

400 IncorrectStatus.VpcDhcpStatus The DhcpOptionsSet status of vpc does not support this operation. The status of the DHCP options set in the current VPC does not support VPC deletion.
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 before you delete the VPC.
400 IncorrectVpcStatus Current VPC status does not support this operation.
400 DependencyViolation.RouteEntry Specified object has dependent resources The current VPC contains custom route entries that have not been deleted. Failed to delete the VPC.
400 DependencyViolation.Instance Specified object has dependent resources
400 DependencyViolation.VSwitch Specified object has dependent resources The current VPC contains vSwitches that have not been deleted. Failed to delete the VPC. Delete the vSwitches in the VPC 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. The VPC contains NAT gateways and cannot be deleted. Delete the NAT gateways in the VPC before you delete the VPC.
400 DependencyViolation.RouterInterface Specified object has dependent resources RouterInterface.
400 DependencyViolation.SecurityGroup Specified object has dependent resources SecurityGroup. The current VPC contains security groups that have not been deleted. Failed to delete the VPC. Delete the security groups in the VPC before you delete the VPC.
400 Forbidden.VpcNotFound Specified VPC can not found. The specified VPC does not exist. Check whether the VPC is correct.
400 Forbbiden Active custom route in vpc.
400 TaskConflict The eip operate too frequent, TaskConflict. The operation is too frequent and a task conflict has occurred.
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 current CBN status is invalid.
400 DependencyViolation.RouteTable Specified object has dependent custom routeTable.
400 DependencyViolation.NetworkAcl Specified object has dependent resources network acl. The specified object has dependent network ACL resources.
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 current VPC contains DHCP options sets that have not been deleted. The deletion is not allowed.
400 InvalidRegionId.NotFound The specified region is not found. The specified region does not exist.
400 DependencyViolation.CustomRouteTable CustomRouteTable already exists. Dependency conflict. A custom route table exists.
400 DependencyViolation.Ipv4Gateway The VPC cannot be deleted when it has ipv4Gateway. The VPC contains an IPv4 gateway and cannot be deleted.
400 DependencyViolation.GatewayRouteTable Specified object has dependent resources gatewayRouteTable.
400 OperationDenied.VpcPeerExists The operation is not allowed because the VpcPeer exists. The specified operation is not allowed because a VPC peering connection exists in the VPC.
400 DependencyViolation.AppAccess Specified object has dependent resources app access. The VPC has a reverse access authorization relationship and cannot be deleted.
400 DependencyViolation.OppositeRouterInterface Failed to delete the VPC because it has peer router interfaces. The peer router interface of the VPC has not been deleted. Failed to delete the VPC.
400 DependencyViolation.TransitRouter Specified object has attached to Transit Router. The specified resource is depended on by other resources. The current operation is not allowed.
400 DependencyViolation.Ipv6Gateway The VPC contains IPv6Gateway and cannot be deleted. The VPC contains an IPv6 gateway and cannot be deleted.
400 DependencyViolation.CloudServiceResource The VPC contains CloudServiceResource and cannot be deleted. The VPC contains cloud service resources and cannot be deleted.
400 IncorrectStatus.VpcDnsHostnameStatus The DnsHostname status of vpc does not support this operation. The DNS hostname 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 VPC is attached to ECR %s and cannot be deleted.
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.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.