Ajeet Raina I am a Docker Captain, ARM Innovator & Docker Bangalore Community Leader. I am a maintainer of Collabnix blogging site. I work for Docker as a full-time employee. I run Collabnix Community Slack with over 6500+ audience . We have built a popular projects like Docker Labs, KubeLabs, KubeTools and DockerTools. You can follow me on Twitter(@ajeetsraina) & GitHub(@ajeetraina)

2 Minutes to “Nuke” Your AWS Cloud Resources

2 min read

Are you seriously looking out for a tool that can save your AWS 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?

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina I am a Docker Captain, ARM Innovator & Docker Bangalore Community Leader. I am a maintainer of Collabnix blogging site. I work for Docker as a full-time employee. I run Collabnix Community Slack with over 6500+ audience . We have built a popular projects like Docker Labs, KubeLabs, KubeTools and DockerTools. You can follow me on Twitter(@ajeetsraina) & GitHub(@ajeetraina)

What is a Dockerfile – A Step-By-Step Guide

A Dockerfile is a text file which contains a series of commands or instructions. These instructions are executed in the order in which they...
Ajeet Raina
21 min read

Docker Desktop for Linux,  Docker Extensions and more with…

Docker Desktop 4.8.2 is now available for download for Mac, Windows and Linux. Here are the major highlights: Docker Desktop for various Linux distributions made available for the first...
Ajeet Raina
1 min read

One Reply to “2 Minutes to “Nuke” Your AWS Cloud Resources”

Leave a Reply