1 minute read

As part of my day job I help administer an IBM Cloud account for our organization. Over 50 people have access to spin up just about anything they want on the account. You can imagine that this leads to a good chunk of spending. As noted by Corey Quinn below, this is becoming an increasingly common problem.

There will inevitably be many processes and tools to solve the problem of cloud spend. One popular tool to use for AWS spend is AWS Nuke. It is built using Go and the AWS Go SDK.

Unfortunately, there is no equivalent SDK (as far as I know) for all common IBM Cloud services. Instead I decided to go old-school and write something in Bash that could using the IBM Cloud CLI. If you’re looking for a resource to learn more about Bash, check out the BASH Cheat Sheet on PCWDLD.

IBM Cloud Nuke is available to try. It will list and delete many IBM Cloud resources and attempt to delete them. Some safety measure have been put in place. A dry run is run by default that lists the resources that will be deleted. A -n flag must be specified in order to actually delete resources. And, a -c flag can be used to specify a file that contains IDs and names of resources that will not be deleted.

An example run can be seen below:

$ ./main.sh
Attempting to use config file at default location: .ibmcloud-nuke
No (-n) flag found. Will NOT delete any resources.
=================================
DRY_RUN = 1
CONFIG_FILE = .ibmcloud-nuke
=================================
=================================
Clusters:
=================================
GAMA-CP4APP-DEMO
Kubeflow-Faz
skipping Kubeflow-Faz as it exists in .ibmcloud-nuke
emea-workshop-tekton
iksmdp

Summary

I hope the project is useful to folks who have a messy account like I did. Please provide feedback as issues or PRs.

Updated: