Deleting a VM
Warning
Deleting a VM is permanent and cannot be undone, so you cannot recover a deleted VM.
When selecting a disk to attach to your VM, you can specify whether to delete that disk when deleting the VM. You can enable this option when creating or updating a VM, or when attaching a new disk to it.
Disks attached to a VM prior to its deletion will automatically be detached. The disk data will be preserved, and you will be able to attach these disks to another VM when needed.
-
In the management console
, select the folder the VM belongs to. -
Select Compute Cloud.
-
In the line with the VM, click
and select Delete.To delete multiple VMs, select them from the list and click Delete at the bottom of the screen.
-
In the window that opens, click Delete.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
-
See the description of the CLI command for deleting a VM:
yc compute instance delete --help
-
Get a list of VMs in the default folder:
yc compute instance list
Result:
+----------------------+-----------------+---------------+---------+----------------------+ | ID | NAME | ZONE ID | STATUS | DESCRIPTION | +----------------------+-----------------+---------------+---------+----------------------+ | fhm0b28lgfp4******** | first-instance | ru-central1-a | RUNNING | my first vm via CLI | | fhm9gk85nj7g******** | second-instance | ru-central1-a | RUNNING | my second vm via CLI | +----------------------+-----------------+---------------+---------+----------------------+
-
Select
ID
orNAME
of the VM, e.g.,first-instance
. -
Delete the VM:
yc compute instance delete first-instance
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To delete a VM created using Terraform, follow these steps:
-
In the command line, go to the directory with the Terraform configuration file.
-
Delete the resources using this command:
terraform destroy
Alert
Terraform will delete all the resources you created in the current configuration, such as clusters, networks, subnets, and VMs.
-
Type
yes
and press Enter.
Use the delete REST API method for the Instance resource or the InstanceService/Delete gRPC API call.