Search code examples
ibm-cloudibm-cloud-infrastructure

delete all resources in a resource group in ibmcloud?


Is there a convenient way to delete all resources in a resource group in ibmcloud? Or even delete the whole resouce group at once?

I have multiple resource groups in my account that need to be deleted with dozens of resources each. Is there a descent way to automate this via the "ibmcloud cli" or even do it via the UI?


Solution

  • I prefer to delete resources using the CLI. There are

    Both commands have a force option. Some service instances can only be deleted when there are no crucial dependencies. An example might be that there is still a root key managed by Key Protect or some COS storage buckets are not empty. You need to look into how to handle that.

    You should also be aware of resource reclamation. Some resources are not deleted immediately (when not explicitly stated), but retained for some days.

    There is command provided to clean up everything with a single command ("oops, I deleted my enterprise resources").

    There is the option to write some simple scripting by listing the resources of interest and iterating over them with the delete command.

    You may want to take a look at the scripts provided for IBM Cloud solution tutorials, e.g., https://github.com/IBM-Cloud/vpc-tutorials/blob/master/scripts/vpc-cleanup.sh