Daily Dose of Cloud Learning: AWS Resource Cleanup with Cloud-nuke
Shanoj Kumar V
VP - Senior Technology Architecture Manager @ Citi | LLMs, AI Agents & RAG | Cloud & Big Data | Author
If you’re diving into AWS for testing, development, or experimentation, you know how crucial it is to clean up your environment afterwards. Often, manual cleanup can be tedious, error-prone, and may leave resources running that could cost you later. That’s where Cloud-nuke comes into play?—?a command-line utility designed to automate the deletion of all resources within your AWS account.?
Cloud-nuke is a powerful and potentially destructive tool, as it will delete all specified resources within an account. Users should exercise caution and ensure they have backups or have excluded critical resources before running the tool.
Install Cloud-nuke
Download Cloud-nuke:
Visit the Cloud-nuke GitHub releases page.
Download the appropriate?.exefile for Windows and run the installer.
Windows: You can install cloud-nuke using winget:?
winget install cloud-nuke
Verify Installation:
Open the Command Prompt and type cloud-nuke --version to verify that Cloud-nuke is installed correctly.
Configure AWS CLI with Your?Profile
Install AWS CLI:
If you don’t have the AWS CLI installed, download and install it from here.
Configure AWS CLI:
Open Command Prompt. Run the following command:
领英推荐
aws configure --profile your-profile-name
Provide the required credentials (Access Key ID, Secret Access Key) for your AWS account.
Specify your preferred default region (e.g., us-west-2).
Specify the output format (e.g., json).
Use Cloud-nuke to Clean Up Resources
Run Cloud-nuke with IAM Exclusion:
To ensure no IAM users are deleted, include the --resource-type flag to exclude IAM resources:
cloud-nuke aws --exclude-resource-type iam
This command will target all resources except IAM.
Bonus Commands:
aws configure list-profiles
aws configure list --profile your-profile-name
This command will display the following details:
I hope this article helps those who plan to use Cloud-nuke. It’s a handy tool that can save you time and prevent unnecessary costs by automating the cleanup process after you’ve tried out resources in your AWS account.