Cloud Nuke — Wipe AWS Resources with a Single Command
A CLI tool from Gruntwork for cleaning up AWS accounts by deleting all resources across regions. Cloud Nuke is essential for tearing down sandbox environments, reducing cloud costs, and preventing resource sprawl.
What it is
Cloud Nuke is a CLI tool from Gruntwork that deletes AWS resources across all regions in a single command. It supports EC2 instances, S3 buckets, Lambda functions, IAM roles, VPCs, RDS databases, and dozens of other resource types. You can filter by resource type, region, age, and tags.
Cloud Nuke targets DevOps engineers and platform teams who manage sandbox, development, and testing AWS accounts. It solves the problem of resource sprawl where forgotten resources accumulate and generate unexpected cloud bills.
How it saves time or tokens
Manually deleting AWS resources through the console requires clicking through each service in each region. Cloud Nuke automates this across all regions and resource types in seconds. For organizations with multiple sandbox accounts, running Cloud Nuke on a schedule prevents cost surprises from forgotten resources.
How to use
- Install Cloud Nuke via Homebrew or download the binary.
- Configure AWS credentials.
- Run the nuke command with appropriate filters.
# Install
brew install cloud-nuke
# Delete ALL resources in an account (dangerous)
cloud-nuke aws
# Delete resources older than 24 hours
cloud-nuke aws --older-than 24h
# Delete only specific resource types
cloud-nuke aws --resource-type ec2 --resource-type s3
# Delete resources in specific regions only
cloud-nuke aws --region us-east-1 --region eu-west-1
# Dry run (list what would be deleted)
cloud-nuke aws --dry-run
Example
# cloud-nuke config file for targeted cleanup
# .cloud-nuke.yml
ec2:
include:
names_regex:
- 'dev-.*'
- 'test-.*'
exclude:
names_regex:
- 'prod-.*'
s3:
include:
names_regex:
- '.*-sandbox-.*'
Related on TokRepo
- DevOps tools — Infrastructure management and automation tools
- Automation tools — Scheduled cleanup and maintenance automation
Common pitfalls
- Cloud Nuke deletes resources permanently. There is no undo. Always use --dry-run first and restrict to sandbox accounts. Never run against production AWS accounts.
- Some resources have deletion dependencies (e.g., VPCs cannot be deleted while ENIs are attached). Cloud Nuke handles most dependencies but may fail on complex resource graphs.
- IAM resource deletion can break other accounts if the IAM roles are used cross-account. Exclude IAM resources unless you are certain they are scoped to the target account.
Frequently Asked Questions
No. Cloud Nuke is designed for sandbox and development accounts. Running it on a production account will delete production resources permanently. Use AWS Organizations to isolate sandbox accounts and restrict Cloud Nuke access to those accounts only.
Cloud Nuke supports EC2, S3, Lambda, RDS, DynamoDB, ECS, EKS, IAM, VPC, CloudWatch, SNS, SQS, Elastic Beanstalk, and dozens more. The full list is in the GitHub README. New resource types are added regularly.
Yes. You can run Cloud Nuke as a cron job, Lambda function, or CI/CD pipeline step. A common pattern is to schedule nightly cleanup of resources older than 48 hours in sandbox accounts. Use the --force flag to skip confirmation prompts in automated runs.
Cloud Nuke scans all enabled AWS regions by default. It queries each region in parallel for supported resource types and deletes them. You can restrict to specific regions using the --region flag if you only want to clean certain regions.
Yes. You can use the config file to include or exclude resources based on name patterns. Tag-based filtering is supported through name regex patterns. This lets you protect specific resources while nuking everything else in a sandbox account.
Citations (3)
- Cloud Nuke GitHub— Cloud Nuke deletes all AWS resources across regions
- Gruntwork Official Site— Gruntwork infrastructure as code tools for AWS
- AWS Cost Management Docs— AWS resource management and cost optimization
Related on TokRepo
Discussion
Related Assets
Moodle — Open-Source Learning Management System
The most widely used open-source learning platform, providing course management, assessments, and collaboration tools for educators and organizations worldwide.
Sylius — Headless E-Commerce Framework on Symfony
An open-source headless e-commerce platform built on Symfony and API Platform, designed for developers who need a customizable and API-first commerce solution.
Akaunting — Free Self-Hosted Accounting Software
A free, open-source online accounting application built on Laravel for small businesses and freelancers to manage invoices, expenses, and financial reports.