Skip to main content

Manually Delete Namespace Resources

We have a script which will delete all of the AWS resources belonging to a given namespace, by running terraform apply with an empty file, and then running kubectl delete namespace.

The script will not do anything if:

a) the namespace folder exists in your local working copy of the environments repository, or

b) the namespace has is-production: "true"

NB: You need ruby installed, in order to use this tool.

To run the script:

  1. populate the environment variables listed in the comment at the top of the script

  2. cd to the root of a working copy of the environments repository

  3. Run bundle install

  4. Run the script, supplying the namespace name as the only argument, e.g.

./bin/delete-namespace.rb mynamespace

If you need to delete a production namespace, you will have to comment out the code which prevents that from happening.

That’s the code block here

If the script fails partway through, it may leave a new file in your local working copy:

namespaces/[namespace name]/resources/

If this happens, just delete the whole namespaces/[namespace name] folder and re-run the script.

This page was last reviewed on 2 June 2021. It needs to be reviewed again on 2 September 2021 by the page owner #cloud-platform .
This page was set to be reviewed before 2 September 2021 by the page owner #cloud-platform. This might mean the content is out of date.