GCP Folder cannot be deleted as it contains active resources

Viewed 1987

Trying to delete a folder in GCP but get the error,

Folder cannot be deleted as it contains active resources. Only empty folders can be deleted.

I suspect there are some hidden resources connected to the folder but I can't figure out what they are (so I can delete them).

2 Answers

As I understand, you are facing an issue while deleting the folder and suspecting there are some hidden resources connected to the folder.

First thing in order to delete the folder you need to have Folder Admin or the Folder Editor role.

Follow the commands below to list the folders underneath a folder

  1. gcloud resource-manager folders list --folder <Folder ID>
  1. gcloud resource-manager folders list --organization <Org ID>
  1. gcloud projects list --filter=" parent.id: <Parent folder ID/ Organization ID>

Once you identified active resources connected to the folder then finally you can run the below command to delete the folder.

gcloud resource-manager folders delete <FOLDER_ID>

For further reading please follow the links below:

To resolve this there were firewall policies attached to the folders, one must have to remove the associations of firewall-policies and then magic happens and you will be able to delete the folder.

I want to remove fld-staging folder then I need to remove the associated firewall-policy to delete the folder:
I want to remove fld-staging folder then I need to remove the associated firewall-policy to delete the folder

Related