Deleting a VM
Warning
Deleting a VM is an operation that cannot be canceled or reversed. You cannot restore a deleted VM.
When you select a disk to attach to a VM, you can specify whether that disk should be deleted when deleting the VM. You can choose this option when creating a VM, updating it, or attaching a new disk to it.
If you have disks attached to your VM, the disks will be detached when you delete the VM. 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 appropriate VM, click
, and then click Delete.To delete multiple VMs, select the VMs you need to delete in 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 command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View a description of the CLI instance delete command below:
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 the
ID
orNAME
of the VM, e.g.,first-instance
. -
Delete the VM instance:
yc compute instance delete first-instance
If you don't have Terraform, install it and configure the Yandex Cloud provider.
If you created an instance using Terraform, you can delete it:
-
In the command line, go to the directory with the Terraform configuration file.
-
Delete the resources using this command:
terraform destroy
Alert
Terraform deletes all the resources that you created in the current configuration, such as clusters, networks, subnets, and instances.
-
Type
yes
and press Enter.
Use the delete REST API method for the Instance resource or the InstanceService/Delete gRPC API call.