Skip to content

Nuke a whole some resources in a DigitalOcean account.

License

Notifications You must be signed in to change notification settings

ciro-mota/cyber-do

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cyber DigitalOcean

License DigitalOcean Shell Script Github Action

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.

⚠️ Caution!

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:

  1. By default only a few paid features are covered by this script: Droplets (VMs), Kubernetes, Volumes, Databases and NodeBalancers.

  2. 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.

  3. 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.

💸 Use Cases

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.

🚀 Installation

  • Create a DigitalOcean Personal Access Token.
  • Name it.
  • Clone this repo.
  • Create a repository secret (Settings » Secret and variables » Actions » New repository secret) named DO_TOKEN and insert your DigitalOcean Personal Access Token.

💻 Usage

  • Edit the do-nuke.yml uncommenting lines 4 and 5 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 * * *"

🐳 Docker

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.

🤝 Referral

Need fast and affordable cloud hosting? Try @digitalocean using my affiliate link and get free credits to get started:

DigitalOcean Referral Badge

🎁 Sponsoring

If you like this work, give me it a star on GitHub, and consider supporting it buying me a coffee:

PayPal