Just like the Cybermans, Delete resources from your DigitalOcean account.
This project is inspired by what is aws-nuke for automatic resource removal from an cloud provider account. And completely based on my other project, the dalek-linode.
Be aware of the risks, you should not use this script in a production account.
To reduce the range and mitigate some problems there are some safety precautions:
-
By default only a few paid features are covered by this script: Droplets (VMs), Kubernetes, Volumes, Databases and NodeBalancers.
-
Also by default, the script will check for the existence of tags with the string name
prod
or related tags and will ignore removing the resource that is associated with this tag. -
This script will not read or remove any other resources than those listed above.
Important
It is not possible to locate Databases via CLI using tags, although it is possible to insert them through the web admin, this tool will then check for the presence of tags with the string name prod
or related in the DB name to determine whether it will be removed or not.
Note
Spaces (S3) are not covered due to the characteristics of the function.
DigitalOcean charges you for the use of VMs even if they are in a powered off state and this can cause a huge cost issue for some people. So you can never simply forget to remove your instances after some testing. Including your tests with Terraform that may have failed to apply or you forgot to destroy
when finished.
With this script your resources will be deleted days at a time pre-scheduled by you with the help of GitHub actions.
- Create a DigitalOcean Personal Access Token.
- Name it.
- Clone this repo.
- Create a repository secret (
Settings
»Secret and variables
»Actions
»New repository secret
) namedDO_TOKEN
and insert your DigitalOcean Personal Access Token.
- Edit the
do-nuke.yml
uncommenting lines4
and5
and adjust the period in which you want the removal action to be performed. By default it will run daily at 3:33am.
schedule:
- cron: "33 3 * * *"
You can also use a Docker container to run the script manually when you want.
- Clone this repo.
- In the Dockerfile file, edit the
DO_CLI_TOKEN
variable and insert your DigitalOcean Personal Access Token. - Build.
- Exec.
Need fast and affordable cloud hosting? Try @digitalocean using my affiliate link and get free credits to get started:
If you like this work, give me it a star on GitHub, and consider supporting it buying me a coffee: