[Yandex Cloud documentation](../../../index.md) > [Yandex Compute Cloud](../../index.md) > [Step-by-step guides](../index.md) > Managing a VM > Deleting a VM

# Deleting a VM

{% note warning %}

Deleting a VM is permanent and cannot be undone, so you cannot recover a deleted VM.

{% endnote %}

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.

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder this VM belongs to.
  1. Navigate to **Compute Cloud**.
  1. Next to the VM you want to delete, click ![image](../../../_assets/console-icons/ellipsis.svg) → **Delete**.

     To delete multiple VMs, select them from the list and click **Delete** at the bottom of the screen.

  1. In the window that opens, click **Delete**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. See the description of the CLI command for deleting a VM:

     ```bash
     yc compute instance delete --help
     ```

  1. Get a list of VMs in the default folder:

     ```bash
     yc compute instance list
     ```
     
     Result:
     ```text
     +----------------------+-----------------+---------------+---------+----------------------+
     |          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 |
     +----------------------+-----------------+---------------+---------+----------------------+
     ```

  1. Select the `ID` or `NAME` of the VM, e.g., `first-instance`.
  1. Delete the VM:

     ```bash
     yc compute instance delete first-instance
     ```

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  To delete a VM created using Terraform, follow these steps:
  1. In the command line, navigate to the directory with the Terraform configuration file.
  1. Delete the resources using this command:

     ```bash
     terraform destroy
     ```

     {% note alert %}

     Terraform will delete all the resources you created in the current configuration, such as clusters, networks, subnets, and VMs.

     {% endnote %}

  1. Type `yes` and press **Enter**.

- API {#api}

  Use the [delete](../../api-ref/Instance/delete.md) REST API method for the [Instance](../../api-ref/Instance/index.md) resource or the [InstanceService/Delete](../../api-ref/grpc/Instance/delete.md) gRPC API call.

{% endlist %}