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 main.tf 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 folder in your local working copy:

namespaces/live.cloud-platform.service.justice.gov.uk/[namespace name]

If this happens, just delete the whole namespaces/live.cloud-platform.service.justice.gov.uk/[namespace name] folder and re-run the script.

This page was last reviewed on 28 November 2022. It needs to be reviewed again on 28 February 2023 by the page owner #cloud-platform .
This page was set to be reviewed before 28 February 2023 by the page owner #cloud-platform. This might mean the content is out of date.