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:
populate the environment variables listed in the comment at the top of the script
cd to the root of a working copy of the environments repository
Run
bundle install
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.