Deleting a folder
To delete a folder, you must have the resource-manager.editor role or higher for that folder. If you cannot perform this operation, contact an administrator or the folder owner.
- On the management console home page
, select the folder. This page displays folders for the selected cloud. You can switch to another cloud, if required. - Click
next to the folder and select Delete. - 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. - Click Delete.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
-
View a description of the folder delete command:
yc resource-manager folder delete --help
-
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:
yc resource-manager folder list
Result:
+----------------------+--------------------+--------+--------+-------------+ | 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:
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 theb1gpvjd9ir42********
folder:yc compute instance get fhmp74bfis2a********
Result:
id: fhmp74bfis2a******** folder_id: b1gpvjd9ia42******** ...
-
-
Delete the folder by specifying its name or ID:
yc resource-manager folder delete <folder_name_or_ID> \ --delete-after <folder_deletion_delay> \ --async
Where:
-
--delete-after
: Folder deletion delay inHhMmSs
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:
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. -
-
(Optional) Get information about the deletion operation status:
yc operation get <operation_ID>
Once the folder deletion is over, the output will contain the
done
field set totrue
(done: true
).
For more information about the yc resource-manager folder delete
command, see the CLI reference.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To delete a folder created with Terraform:
-
Open the Terraform configuration file and delete the fragment describing the folder.
Example folder description in a Terraform configuration
... resource "yandex_resourcemanager_folder" "folder1" { cloud_id = "b1gia12lt1tp********" name = "new-folder" description = "this is my default-folder" } ...
For more information about the
yandex_resourcemanager_folder
resource parameters in Terraform, see the relevant provider documentation . -
In the command line, go to the folder with the Terraform configuration file.
-
Check the configuration using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
The terminal will display a list of resources with parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
into the terminal and press Enter.You can check the folder deletion using the management console
or this CLI command:yc resource-manager folder list
To delete a folder, use the delete REST API method for the Folder resource or the FolderService/Delete gRPC API call.
The resources will be stopped, and the folder status will change to PENDING_DELETION
. You can cancel the deletion of a folder that is PENDING_DELETION
. To do this, click the
Alert
While a folder is PENDING_DELETION
, your disks, reserved IPs, and other data are still stored and billed.
While a folder is PENDING_DELETION
, you are still charged for paid resources if metrics detect their consumption.
The cost of such storage is charged at the previous rate. Track your resource costs in Yandex Cloud Billing
Once the waiting timeout expires, the folder status will change to DELETING
. 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. Once the deletion is canceled, the folder will regain its ACTIVE
status, and the user will get a message stating why the folder could not be deleted.