[Yandex Cloud documentation](../../../index.md) > [Yandex Resource Manager](../../index.md) > [Step-by-step guides](../index.md) > Folder > Deleting a folder

# Deleting a folder

To delete a [folder](../../concepts/resources-hierarchy.md#folder), you must have the [resource-manager.editor](../../security/index.md#resource-manager-editor) role or higher for that folder. If you cannot perform this operation, contact an [administrator](../../../iam/roles-reference.md#admin) or the [folder owner](../../concepts/resources-hierarchy.md#owner).

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), click ![image](../../../_assets/console-icons/layout-side-content-left.svg) or ![image](../../../_assets/console-icons/chevron-down.svg) in the top panel and select the folder. You can [switch to another cloud](../cloud/switch-cloud.md), if required.
  1. Click ![image](../../../_assets/console-icons/ellipsis.svg) to the right of the folder name.
  1. Select ![image](../../../_assets/console-icons/trash-bin.svg) **Delete folder**.

     ![delete-folder1](../../../_assets/resource-manager/delete-folder-1.png)

  1. Select a folder deletion delay: a time period after which the folder will be deleted. Select one of the suggested periods or `Delete now`. The default folder deletion delay is 7 days.
  1. Enter the folder name to confirm deletion. 
  1. Click **Delete**.

     ![delete-folder2](../../../_assets/resource-manager/delete-folder-2.png)

- CLI {#cli}

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

  1. View a description of the folder delete command:

      ```bash
      yc resource-manager folder delete --help
      ```

  1. If you know the folder ID or name, proceed to the next step. Otherwise, use one of these methods to get them:
     
     * Get a list of folders:
       ```bash
       yc resource-manager folder list
       ```
     
       Result:
     
       ```text
       +----------------------+--------------------+--------+--------+-------------+
       |          ID          |        NAME        | LABELS | STATUS | DESCRIPTION |
       +----------------------+--------------------+--------+--------+-------------+
       | b1gppulhhm2a******** | yet-another-folder |        | ACTIVE |             |
       | b1gvmob95yys******** | default            |        | ACTIVE |             |
       +----------------------+--------------------+--------+--------+-------------+
       ```
     
       * If you know the ID of the resource that belongs to the required folder, you can get the folder ID from the information about that resource:
     
       ```bash
       yc <service_name> <service_category> get <resource_ID>
       ```
     
       Where:
       * `<service_name>`: Service name, e.g., `compute`.
       * `<service_category>`: Resource category, e.g., `instance`.
       * `<resource_ID>`: Resource ID.
     
       For example, the `fhmp74bfis2a********` VM belongs to the `b1gpvjd9ir42********` folder:
     
       ```bash
       yc compute instance get fhmp74bfis2a********
       ```
     
       Result:
     
       ```text
       id: fhmp74bfis2a********
       folder_id: b1gpvjd9ia42********
       ...
       ```

  1. Delete the folder by specifying its name or ID:

      ```bash
      yc resource-manager folder delete <folder_name_or_ID> \
        --delete-after <folder_deletion_delay> \
        --async
      ```

      Where:

      * `--delete-after`: Folder deletion delay in `HhMmSs` format. Folder deletion process will start after the specified delay. For example, `--delete-after 22h30m50s`.

          Specify `0s` to delete the folder now.
      * `--async`: Asynchronous deletion flag.
      
          Deleting a folder can take up to 72 hours. Run the command in asynchronous mode to return to terminal management without waiting for the command to complete.

      Result:

      ```text
      id: b1gqkbbj04d9********
      description: Delete folder
      created_at: "2024-10-17T05:16:30.648219069Z"
      created_by: ajei280a73vc********
      modified_at: "2024-10-17T05:16:30.648219069Z"
      metadata:
        '@type': type.googleapis.com/yandex.cloud.resourcemanager.v1.DeleteFolderMetadata
        folder_id: b1g66mft1vop********
        delete_after: "2024-10-18T03:47:19.441433Z"
      ```

      Where `id` is the operation ID you can use to track the operation status later.

  1. (Optional) Get information about the deletion operation status:

      ```bash
      yc operation get <operation_ID>
      ```

      Once the folder deletion is over, the output will contain the `done` field set to `true` (`done: true`).

  For more information about the `yc resource-manager folder delete` command, see the [CLI reference](../../../cli/cli-ref/resource-manager/cli-ref/folder/delete.md).

- 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 folder created with Terraform:

  1. Open the Terraform configuration file and delete the fragment describing the folder.

      {% cut "Example folder description in a Terraform configuration" %}

      ```hcl
      ...
      resource "yandex_resourcemanager_folder" "folder1" {
        cloud_id    = "b1gia12lt1tp********"
        name        = "new-folder"
        description = "this is my default-folder"
      }
      ...
      ```

      {% endcut %}

      For more on the properties of the `yandex_resourcemanager_folder` resource in Terraform, see [this provider guide](../../../terraform/resources/resourcemanager_folder.md).

  1. In the command line, navigate to the directory with the Terraform configuration file.

  1. Check the configuration using this command:

      ```
      terraform validate
      ```

      If the configuration is valid, you will get this message:

      ```
      Success! The configuration is valid.
      ```

  1. Run this command:

      ```
      terraform plan
      ```

      You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.

  1. Apply the configuration changes:

      ```
      terraform apply
      ```

  1. Confirm the changes: type `yes` into the terminal and press **Enter**.

      You can check the folder deletion using the [management console](https://console.yandex.cloud) or this [CLI](../../../cli/quickstart.md) command:

      ```
      yc resource-manager folder list
      ```

- API {#api}

  To delete a folder, use the [delete](../../api-ref/Folder/delete.md) REST API method for the [Folder](../../api-ref/Folder/index.md) resource or the [FolderService/Delete](../../api-ref/grpc/Folder/delete.md) gRPC API call.

{% endlist %}

Deletion starts with stopping resources. The folder enters the `PENDING_DELETION` status. Preparation for deletion starts. The exact time in this status depends on the specified deletion delay. You can cancel the deletion of the folder while it is `PENDING_DELETION`. To do this, click the ![***](../../../_assets/console-icons/ellipsis.svg) icon to the right of the folder name in the [management console](https://console.yandex.cloud/cloud) and select **Cancel deletion**.

{% note alert %}

While a folder is `PENDING_DELETION`, your disks, reserved IPs, and other data are still stored and billed. 

While a folder is `DELETING`, you are still charged for paid resources if metrics indicate their consumption.

The storage cost is calculated at the previous rate. Track how much the resources cost you in [Yandex Cloud Billing](https://center.yandex.cloud/billing/accounts).

{% endnote %}

As soon as the deletion preparation and delay periods are over, the folder enters the `DELETING` status. This status means it is being permanently deleted, which can take up to 72 hours. All the folder's resources will be deleted together with it.

Sometimes, the system may cancel the deletion of a folder if it contains resources that cannot be deleted. For more information, see [Reasons why a folder cannot be deleted](../../concepts/resources-hierarchy.md#inability-to-delete). Once the deletion is canceled, the folder will go back to `ACTIVE` with a message to the user stating the reasons why the folder could not be deleted.