I am trying to create a cron service that cleans up (removes billing and deletes) a bunch of projects and resource folders on GCP for a development team. Ideally, I would like to use cloud functions to do this as its lightweight, however, I can't seem to find any client libraries that would allow for FOLDER deletion. Has anyone been able to find any client libraries to do this?
The other options I am considering are:
- To create a Cloud Run cron service in a container which calls gcloud commands (like this https://cloud.google.com/sdk/gcloud/reference/resource-manager/folders/create).
- Call the GCP Rest API from the cloud function to the resource manager APIS.
You can use the discovery API. We use it in production (only for search and then attach project to a folder)
An example of our python code
Use the delete operation if you want to do this.