52,598 views

Are you seriously looking out for a tool that can save your bills while being a FREE tier user? If you’re one of those new AWS account holders who wants to ensure that all the resources get deleted once you finish your testing work, then you should look at “Cloud Nuke”.

Cloud-Nuke is a tool for cleaning up your cloud accounts by nuking (deleting) all resources within them. It’s open-source tool and hosted under GITHUB.

Why Cloud Nuke is so cool?

With Cloud Nuke, you can get the below list of work completed in just 5 minutes:

  • Deleting all Auto scaling groups in an AWS account
  • Deleting all Elastic Load Balancers (Classic and V2) in an AWS account
  • Deleting all EBS Volumes in an AWS account
  • Deleting all unprotected EC2 instances in an AWS account
  • Deleting all AMIs in an AWS account
  • Deleting all Snapshots in an AWS account
  • Deleting all Elastic IPs in an AWS account
  • Deleting all Launch Configurations in an AWS account
  • Deleting all ECS services in an AWS account
  • Deleting all ECS clusters in an AWS account
  • Deleting all EKS clusters in an AWS account
  • Deleting all RDS DB instances in an AWS account
  • Deleting all Lambda Functions in an AWS account
  • Deleting all S3 buckets in an AWS account – except for buckets tagged with Key=cloud-nuke-excluded Value=true
  • Deleting all default VPCs in an AWS account
  • Revoking the default rules in the un-deletable default security group of a VPC

Without any further delay, let us test drive this tool.

Before using this tool, I had a bunch of EC2 instances up and running for my testing work. These instances were lying around and I really didn’t need them anymore.

Pre-requisite

  • Ensure that you have aws configure configured.

Download

  • Linux System
wget https://github.com/gruntwork-io/cloud-nuke/releases/download/v0.1.24/cloud-nuke_linux_amd64

If you’re on MacOS, ensure that you pick up

wget https://github.com/gruntwork-io/cloud-nuke/releases/download/v0.1.24/cloud-nuke_darwin_amd64

Move the binary to a folder on your PATH.

mv cloud-nuke_darwin_amd64 /usr/local/bin/cloud-nuke.

Add execute permissions to the binary.

chmod u+x /usr/local/bin/cloud-nuke

Test it installed correctly:

cloud-nuke --help.

That’s it. Run the below CLI to clean up the overall AWS resources.

sudo cloud-nuke aws
INFO[2020-12-23T11:33:42Z] The following resource types will be nuked:  
INFO[2020-12-23T11:33:42Z] - ami                                        
INFO[2020-12-23T11:33:42Z] - asg                                        
INFO[2020-12-23T11:33:42Z] - ebs                                        
INFO[2020-12-23T11:33:42Z] - ec2                                        
INFO[2020-12-23T11:33:42Z] - ecscluster                                 
INFO[2020-12-23T11:33:42Z] - ecsserv                                    
INFO[2020-12-23T11:33:42Z] - eip                                        
INFO[2020-12-23T11:33:42Z] - ekscluster                                 
INFO[2020-12-23T11:33:42Z] - elb                                        
INFO[2020-12-23T11:33:42Z] - elbv2                                      
INFO[2020-12-23T11:33:42Z] - lambda                                     
INFO[2020-12-23T11:33:42Z] - lc                                         
INFO[2020-12-23T11:33:42Z] - rds                                        
INFO[2020-12-23T11:33:42Z] - s3                                         
INFO[2020-12-23T11:33:42Z] - snap                                       
INFO[2020-12-23T11:33:43Z] Retrieving active AWS resources in [eu-north-1, ap-south-1, eu-west-3, eu-west-2, eu-west-1, ap-northeast-2, ap-northeast-1, sa-east-1, ca-central-1, ap-southeast-1, ap-southeast-2, eu-central-1, us-east-1, us-east-2, us-west-1, us-west-2] 
INFO[2020-12-23T11:33:43Z] Checking region [1/16]: eu-north-1  

It will ask you to type “nuke” and there you go…

THE NEXT STEPS ARE DESTRUCTIVE AND COMPLETELY IRREVERSIBLE, PROCEED WITH CAUTION!!!

Are you sure you want to nuke all listed resources? Enter 'nuke' to confirm (or exit with ^C): nuke
INFO[2020-12-24T11:47:21Z] Terminating 1 resources in batches           
INFO[2020-12-24T11:47:21Z] Deleting all Elastic Load Balancers in region us-east-1 
INFO[2020-12-24T11:47:21Z] Deleted ELB: af6820e0fc547433a8b8cdc84c636d4a 
INFO[2020-12-24T11:47:21Z] [OK] 1 Elastic Load Balancer(s) deleted in us-east-1 
INFO[2020-12-24T11:47:21Z] Terminating 2 resources in batches           
INFO[2020-12-24T11:47:21Z] Deleting all V2 Elastic Load Balancers in region us-east-1 
INFO[2020-12-24T11:47:21Z] Deleted ELBv2: arn:aws:elasticloadbalancing:us-east-1:567085410233:loadbalancer/net/test-s9jfl-ext/0ecfc28fd2202161 
INFO[2020-12-24T11:47:21Z] Deleted ELBv2: arn:aws:elasticloadbalancing:us-east-1:567085410233:loadbalancer/net/test-s9jfl-int/eb345a2c6cb26c1a 
INFO[2020-12-24T11:47:21Z] [OK] 2 V2 Elastic Load Balancer(s) deleted in us-east-1 
INFO[2020-12-24T11:47:21Z] Terminating 9 resources in batches           
INFO[2020-12-24T11:47:21Z] Terminating all EC2 instances in region us-east-1 
Connection to ec2-3-238-203-58.compute-1.amazonaws.com closed by remote host.
Connection to ec2-3-238-203-58.compute-1.amazonaws.com closed.

By now, I could see that all of these resources getting terminated. Super cool, isn’t it?

Clap

Categories: Docker

Ajeet Raina

My name is Ajeet Singh Raina and I am an author of this blogging site. I am a Docker Captain, ARM Innovator & Docker Bangalore Community Leader. I bagged 2 special awards last year(2019) : Firstly, “The Tip of Captain’s Hat Award” at Dockercon 2019, San Francisco and secondly, “2019 Docker Community Award“. I run Collabnix Community Slack with over 4700+ audience as well as Redis Community Slack with close to 500+ members. I have built popular GITHUB repositories like DockerLabs, KubeLabs, Kubetools, RedisPlanet Terraform etc. with the support of Collabnix Community. Currently working as Developer Relations Manager at Redis Labs where I help customers and community members adopt Redis. With over 11,000+ followers over LinkedIn & close to 4800+ twitter followers, I like sharing Docker and Kubernetes related content . You can follow me on Twitter(@ajeetsraina) & GitHub(@ajeetraina)

0 Comments

Leave a Reply

Your e-mail address will not be published. Required fields are marked *